Hi i am going to use Array Collection in my project
TaxField Table
| TaxFieldID | Display Name | Print Name |
| FD713788-B5AE-49FF-8B2C-F311B9CB0CC4 | TinNo | TinNo |
| 64B512E7-46AE-4989-A049-A446118099C4 | CstNo | CstNo |
| 59A2449A-C5C6-45B5-AA00-F535D83AD48B | CinNo | CinNo |
| 2F405521-06A0-427C-B9A3-56B8931CFC57 | ServiceTaxNo | ServiceTaxNo |
TaxInfoTaxField Table
| TaxInfoTaxFieldID | TaxFieldID | Field Value |
| NewGuid() | TinNo Eg(FD713788-B5AE-49FF-8B2C-F311B9CB0CC4) | TinNo |
| NewGuid() | CstNoEg(64B512E7-46AE-4989-A049-A446118099C4) | CstNo |
| NewGuid() | CinNoEg(59A2449A-C5C6-45B5-AA00-F535D83AD48B) | CinNo |
| NewGuid() | ServiceTaxNo Eg(2F405521-06A0-427C-B9A3-56B8931CFC57) | ServiceTaxNo |
My View Contain 6 fields TinNo, CstNo, PanNo, ServiceTaxNo, CinNo, ExciseRegNo. I need to save these six fields in TaxInfoTaxField Table in the above format. Each fiels have Default value which is mentioned in the TaxField Table.
Now i am going to use Array not Array list collection to save these values in tables . I want to set Array Size as 6 before i used for each loop to save these values in table but it is not working.
That is
My Model
public partial class TaxFieldModel
{
public System.Guid TaxFieldID { get; set; }
public string DisplayName { get; set; }
public string PrintName { get; set; }
}
public partial class TaxInfoTaxFiledModel
{
public System.Guid TaxInfoTaxFieldID { get; set; }
public Nullable TaxInfoID { get; set; }
public Nullable TaxFieldID { get; set; }
public string FieldValue { get; set; }
}
My ViewModel
public class CustomerViewModel
{
public string TinNo { get; set; }
public string CstNo { get; set; }
public string ExciseRegNo { get; set; }
public string PanNo { get; set; }
public string ServiceTaxNo { get; set; }
public string CinNo { get; set; }
public List TaxFields { get; set; }
public List Tfs { get; set; }
public class VisitorsEntities1 : DbContext
{
public DbSet TaxField { get; set; }
public DbSet TaxInfoTaxFiled { get; set; }
}My Controller
ArrayList Alist = new ArrayList();
{
Alist.Add("FD713788-B5AE-49FF-8B2C-F311B9CB0CC4");
Alist.Add("64B512E7-46AE-4989-A049-A446118099C4");
Alist.Add("376D45C8-659D-4ACE-B249-CFBF4F231915");
Alist.Add("59A2449A-C5C6-45B5-AA00-F535D83AD48B");
Alist.Add("03ADA903-D09A-4F53-8B67-7347A08EDAB1");
Alist.Add("2F405521-06A0-427C-B9A3-56B8931CFC57");
}
ArrayList objValue=new ArrayList();
{
objValue.Add(viewmodel.TinNo);
objValue.Add(viewmodel.CstNo);
objValue.Add(viewmodel.PanNo);
objValue.Add(viewmodel.CinNo);
objValue.Add(viewmodel.ExciseRegNo);
objValue.Add(viewmodel.ServiceTaxNo);
}
foreach(var tax in Alist)
foreach (var tax in viewmodel.Tfs )
{
foreach (var i in Alist)
{
tax.FieldTypeID = Guid.Parse(i.ToString());
}
foreach (var j in objValue)
{
tax.FieldValue = j.ToString();
}
db.TaxInfoTaxFiled.Add(tax);
}
1) First Have to declare the Size of Array is 6 ( because it contain Six fields) before that i need to save those Default Guid Id's in Array
eg
Guid[] Alist = new Guid[6];
new Guid("FD713788-B5AE-49FF-8B2C-F311B9CB0CC4");
new Guid ("64B512E7-46AE-4989-A049-A446118099C4");
new Guid("376D45C8-659D-4ACE-B249-CFBF4F231915");
new Guid("59A2449A-C5C6-45B5-AA00-F535D83AD48B");
new Guid("03ADA903-D09A-4F53-8B67-7347A08EDAB1");
new Guid("2F405521-06A0-427C-B9A3-56B8931CFC57");
I donno this is correct or not and next i have to save that six fields in view model in Array . How to do that ArrayList objValue=new ArrayList();
{
objValue.Add(viewmodel.TinNo);
objValue.Add(viewmodel.CstNo);
objValue.Add(viewmodel.PanNo);
objValue.Add(viewmodel.CinNo);
objValue.Add(viewmodel.ExciseRegNo);
objValue.Add(viewmodel.ServiceTaxNo);
}
Thanks..
Sneha KPosted Dec 11, 2015, 11:07 PM
Hitesh PatilPosted Dec 11, 2015, 8:40 AM
http://thereferraltask.net/?ref109534