Ejemplo n.º 1
0
        protected void ucConfirmDialog_Yes(object sender)
        {
            ucConfirmDialog.Hide();

            try
            {
                Admins        vcontroller = new Admins();
                Entities.Size vsize       = new Entities.Size();
                string        errMsg      = string.Empty;
                vsize.Masize = Convert.ToInt32(lblsize.Text);
                vsize.Size1  = txttensize.Text;
                int result = vcontroller.save_Size(vsize, ref errMsg);
                if (result > 0)
                {
                    ucNotificationDialog.MessageContent = "Thêm mới size thành công!";
                    ucNotificationDialog.MessageType    = 1;
                    ucNotificationDialog.RedirectUrl    = "~/Admin/Sizes.aspx";
                    ucNotificationDialog.Show();
                }
                else
                {
                    NotificationMessage("Vui lòng kiểm tra lại.", 0);
                }
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
                ucNotificationDialog.MessageContent = "Hệ thống gặp sự cố trong quá trình cập nhật !";
                ucNotificationDialog.MessageType    = 0;
                ucNotificationDialog.Show();
            }
        }
Ejemplo n.º 2
0
 public Domain.Abstracts.ASize Update(Domain.Abstracts.ASize updated)
 {
     Entities.Size dbSize = mapper.Map(updated, context, true);
     context.SaveChanges();
     //context.ChangeTracker.Clear();
     return(mapper.Map(dbSize));
 }
Ejemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            if (string.IsNullOrEmpty(txttensize.Text))
            {
                NotificationMessage("tên size không được để trống", 0);
                return;
            }
            try
            {
                Admins vcontroller = new Admins();
                Entities.Size vsize = new Entities.Size();
                string errMsg = string.Empty;
                vsize.Masize = COMM.Common.GetID_MaxForInsert("[dbo].[Size]", "[MaSize]", "");
                vsize.Size1 = txttensize.Text;
                int result = vcontroller.save_Size(vsize, ref errMsg);
                if (result > 0)
                {
                    ucNotificationDialog.MessageContent = "Thêm mới size thành công!";
                    ucNotificationDialog.MessageType = 1;
                    ucNotificationDialog.RedirectUrl = "~/Admin/Sizes.aspx";
                    ucNotificationDialog.Show();
                }
                else
                {
                    NotificationMessage("Vui lòng kiểm tra lại.", 0);
                }

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                NotificationMessage("Hệ thống gặp sự cố trong quá trình thêm user mới!", 0);
            }
        }
        public Entities.Size Map(Domain.Models.Size model, Entities.AnimalsDbContext context)
        {
            Entities.SIZE_TYPE sizeType;
            switch (model)
            {
            case Domain.Models.SmallSize:
                sizeType = Entities.SIZE_TYPE.Small;
                break;

            case Domain.Models.MediumSize:
                sizeType = Entities.SIZE_TYPE.Medium;
                break;

            case Domain.Models.LargeSize:
                sizeType = Entities.SIZE_TYPE.Large;
                break;

            default:
                throw new ArgumentException("SizeMapper encountered an unknown type when mapping from Domain Model to DB Model");
            }
            var dbSize = context.Sizes.FirstOrDefault(s => s.SizeType == sizeType);

            if (dbSize is not null)
            {
                return(dbSize);
            }

            Entities.Size size = new Entities.Size();
            size.SizeType = sizeType;
            size.Price    = model.Price;
            return(size);
        }
Ejemplo n.º 5
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txttensize.Text))
     {
         NotificationMessage("tên size không được để trống", 0);
         return;
     }
     try
     {
         Admins        vcontroller = new Admins();
         Entities.Size vsize       = new Entities.Size();
         string        errMsg      = string.Empty;
         vsize.Masize = COMM.Common.GetID_MaxForInsert("[dbo].[Size]", "[MaSize]", "");
         vsize.Size1  = txttensize.Text;
         int result = vcontroller.save_Size(vsize, ref errMsg);
         if (result > 0)
         {
             ucNotificationDialog.MessageContent = "Thêm mới size thành công!";
             ucNotificationDialog.MessageType    = 1;
             ucNotificationDialog.RedirectUrl    = "~/Admin/Sizes.aspx";
             ucNotificationDialog.Show();
         }
         else
         {
             NotificationMessage("Vui lòng kiểm tra lại.", 0);
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
         NotificationMessage("Hệ thống gặp sự cố trong quá trình thêm user mới!", 0);
     }
 }
Ejemplo n.º 6
0
        public Domain.Abstracts.ASize Map(Entities.Size model)
        {
            Domain.Abstracts.ASize size;
            switch (model.SizeType)
            {
            case SIZE_TYPE.Small:
                size = new Domain.Models.SmallSize();
                break;

            case SIZE_TYPE.Medium:
                size = new Domain.Models.MediumSize();
                break;

            case SIZE_TYPE.Large:
                size = new Domain.Models.LargeSize();
                break;

            default:
                throw new ArgumentException("SizeMapper encountered an unknown type when mapping from DB Model to Domain Model");
            }
            size.Price    = model.Price;
            size.ID       = model.ID;
            size.Name     = model.Name;
            size.SizeType = model.SizeType;
            return(size);
        }
Ejemplo n.º 7
0
        public Entities.Size Map(Domain.Models.Size model)
        {
            Entities.SIZE_TYPE sizeType;
            switch (model)
            {
            case Domain.Models.SmallSize:
                sizeType = Entities.SIZE_TYPE.Small;
                break;

            case Domain.Models.MediumSize:
                sizeType = Entities.SIZE_TYPE.Medium;
                break;

            case Domain.Models.LargeSize:
                sizeType = Entities.SIZE_TYPE.Large;
                break;

            default:
                throw new ArgumentException("SizeMapper encountered an unknown type when mapping from Domain Model to DB Model");
            }
            Entities.Size size = new Entities.Size();
            size.SizeType = sizeType;
            size.Price    = model.Price;
            return(size);
        }
Ejemplo n.º 8
0
        protected void ucConfirmDialog_Yes(object sender)
        {
            ucConfirmDialog.Hide();

            try
            {

                Admins vcontroller = new Admins();
                Entities.Size vsize = new Entities.Size();
                string errMsg = string.Empty;
                vsize.Masize = Convert.ToInt32(lblsize.Text);
                vsize.Size1 = txttensize.Text;
                int result = vcontroller.save_Size(vsize, ref errMsg);
                if (result > 0)
                {
                    ucNotificationDialog.MessageContent = "Thêm mới size thành công!";
                    ucNotificationDialog.MessageType = 1;
                    ucNotificationDialog.RedirectUrl = "~/Admin/Sizes.aspx";
                    ucNotificationDialog.Show();
                }
                else
                {
                    NotificationMessage("Vui lòng kiểm tra lại.", 0);
                }
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
                ucNotificationDialog.MessageContent = "Hệ thống gặp sự cố trong quá trình cập nhật !";
                ucNotificationDialog.MessageType = 0;
                ucNotificationDialog.Show();
            }
        }
Ejemplo n.º 9
0
 public void Remove(Domain.Models.Size t)
 {
     Entities.Size dbSize = mapper.Map(t, context);
     Entities.Size size   = context.Sizes.ToList().Find(s => s.SizeType == dbSize.SizeType);
     if (size is not null)
     {
         context.Remove(size);
         context.SaveChanges();
     }
 }
Ejemplo n.º 10
0
 public void Remove(int id)
 {
     Entities.Size size = context.Sizes.FirstOrDefault(s => s.ID == id);
     if (size is not null)
     {
         context.Remove(size);
         context.SaveChanges();
         //context.ChangeTracker.Clear();
     }
 }
Ejemplo n.º 11
0
 public void Update(Domain.Models.Size existing, Domain.Models.Size updated)
 {
     Entities.Size dbSize = mapper.Map(existing, context);
     Entities.Size size   = context.Sizes.ToList().Find(s => s.SizeType == dbSize.SizeType);
     if (size is not null)
     {
         Entities.Size updatedSize = mapper.Map(updated, context);
         size.Price    = updatedSize.Price;
         size.SizeType = updatedSize.SizeType;
         context.SaveChanges();
     }
 }
Ejemplo n.º 12
0
 private void FillData()
 {
     try
     {
         Admins        vcontroller = new Admins();
         Entities.Size vsize       = new Entities.Size();
         string        errMsg      = string.Empty;
         vsize           = vcontroller.getby_size_ID(Request.QueryString["ID"], ref errMsg);
         lblsize.Text    = vsize.Masize.ToString();
         txttensize.Text = vsize.Size1;
     }
     catch (Exception ex) { Response.Write(ex.Message); }
 }
Ejemplo n.º 13
0
        protected async override Task OnInitializedAsync()
        {
            /*var result = await ProtectedSessionStore.GetAsync<PizzaInfo>("PizzaInfo");
             *  PizzaInfo = result.Success ? result.Value : null;
             *  SelectedSize = PizzaInfo.Size.First(); */
            Qty = 1;
            var pizzaInfo = await pizzaService.GetPizzaInfoAsync();

            StateContainer.SetPizzaInfo(pizzaInfo);
            PizzaInfo    = StateContainer.PizzaInfo;
            SelectedSize = PizzaInfo.Size.First();
            UpdatePrice();

            StateContainer.OnChange += StateHasChanged;
        }
Ejemplo n.º 14
0
 public Entities.Size Map(Domain.Abstracts.ASize model, Entities.PizzaBoxDbContext context, bool update = false)
 {
     Entities.Size size = context.Sizes.FirstOrDefault(s => s.ID == model.ID) ?? new Entities.Size();
     if (size.ID != 0 && !update)
     {
         return(size);
     }
     size.SizeType = model.SizeType;
     size.Name     = model.Name;
     size.Price    = model.Price;
     if (size.ID == 0)
     {
         context.Sizes.Add(size);
     }
     return(size);
 }
Ejemplo n.º 15
0
 private void FillData()
 {
     try
     {
         Admins                vcontroller   = new Admins();
         Entities.SanPham      vsanpham      = new Entities.SanPham();
         Entities.Size         vsize         = new Entities.Size();
         Entities.SanPham_Size vsanpham_size = new Entities.SanPham_Size();
         string                errMsg        = string.Empty;
         string[]              listid        = Convert.ToString(Request.QueryString["ID"]).Split(new char[] { ',' });
         int masp   = Convert.ToInt32(listid[0]);
         int masize = Convert.ToInt32(listid[1]);
         vsanpham           = vcontroller.getby_sanpham(masp.ToString(), ref errMsg);
         lbltensanpham.Text = vsanpham.TenSP;
         vsize           = vcontroller.getby_size_ID(masize.ToString(), ref errMsg);
         lblsize.Text    = vsize.Size1;
         vsanpham_size   = vcontroller.getby_sanpham_size(masp, masize, ref errMsg);
         txtsoluong.Text = vsanpham_size.Soluong.ToString();
     }
     catch (Exception ex) { Response.Write(ex.Message); }
 }
        private List <Calf> selectCalfs(SqlCommand cmd)
        {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlConnection con       = cmd.Connection;
            List <Calf>   listCalfs = new List <Calf>();

            con.Open();
            using (con)
            {
                SqlDataReader dr = cmd.ExecuteReader();

                //              [TagNo]                     0
                //   ,[RegistrationDate]                    1
                //   ,[AnimalType]                          2
                //,at.Description                           3
                //   ,[Gender]                              4
                //ID                                            5
                //   ,[BirthDate]                       6
                //   ,[Weight]                      7
                //   ,[Height]                      8
                //   ,[Length]                      9
                //   ,[Width]                       10
                //   ,[Price]                           11
                //   ,[Source]                          12
                //,aso.Description                      13
                //   ,[Breed]                                   14
                //,ab.Description                          15
                //   ,[Status]                                16
                //,ast.Description                     17
                //   ,[OtherDetails]                 18
                //   Mother                                19
                // Mother TagNo                     20              Added Apr-02
                //Father                                   21
                // Father TagNo                    22              Added Apr-02

                if (dr.HasRows)
                {
                    listCalfs = new List <Calf>();
                    while (dr.Read())
                    {
                        AnimalBreed currCattleBreed = new AnimalBreed           //14,15
                        {
                            ID          = Convert.ToInt32(dr[14]),
                            Description = Convert.ToString(dr[15])
                        };

                        AnimalSource currCattleSource = new AnimalSource  //12,13
                        {
                            ID          = Convert.ToInt32(dr[12]),
                            Description = Convert.ToString(dr[13])
                        };
                        AnimalStatus currCattleStatus = new AnimalStatus        //16 , 17
                        {
                            ID          = Convert.ToInt32(dr[16]),
                            Description = Convert.ToString(dr[17])
                        };
                        AnimalType currCattleType = new AnimalType()            //2, 3
                        {
                            ID          = Convert.ToInt32(dr[2]),
                            Description = Convert.ToString(dr[3])
                        };
                        Gender currCattleGender = new Gender()                  //4 , 5
                        {
                            Description = Convert.ToString(dr[4])
                        };

                        PhysicalAttributes currPhysicalAttribs = new PhysicalAttributes();

                        currPhysicalAttribs.Weight = Convert.ToDouble(dr[7]);   //7

                        Entities.Size currSize = new Entities.Size();           //TO avoid ambiguity among .Net's Size function

                        currSize.Height = Convert.ToDouble(dr[8]);
                        currSize.Length = Convert.ToDouble(dr[9]);
                        currSize.Width  = Convert.ToDouble(dr[10]);

                        currPhysicalAttribs.CurrentSize = currSize;

                        Cattle currCalfMother = new Cattle();
                        Cattle currCalfFather = new Cattle();

                        //Added April-02

                        currCalfMother.ID = Convert.ToInt32(dr[20]);

                        if (currCalfMother.ID == 0)
                        {
                            currCalfMother.TagNo = "Other Farm";
                        }
                        else
                        {
                            currCalfMother.TagNo = Convert.ToString(dr[19]);
                        }

                        currCalfFather.ID = Convert.ToInt32(dr[22]);

                        if (currCalfFather.ID == 0)
                        {
                            currCalfFather.TagNo = "Artificial Insemnation";
                        }
                        else
                        {
                            currCalfFather.TagNo = Convert.ToString(dr[21]);
                        }

                        //Addition Ends. April-02

                        Calf currCalf = new Calf
                        {
                            ID               = Convert.ToInt32(dr[5]),
                            TagNo            = Convert.ToString(dr[0]),
                            RegistrationDate = Convert.ToDateTime(dr[1]),
                            BirthDate        = Convert.ToDateTime(dr[6]),
                            Price            = Convert.ToInt32(dr[11]),
                            OtherDetails     = Convert.ToString(dr[18])
                        };

                        currCalf.Mother = currCalfMother;
                        currCalf.Father = currCalfFather;

                        currCalf.Breed  = currCattleBreed;
                        currCalf.Gender = currCattleGender;
                        currCalf.CurrPhysicalAttribs = currPhysicalAttribs;
                        currCalf.Source = currCattleSource;
                        currCalf.Status = currCattleStatus;
                        currCalf.Type   = currCattleType;

                        listCalfs.Add(currCalf);
                    }
                }
            }
            return(listCalfs);
        }
Ejemplo n.º 17
0
 private void FillData()
 {
     try
     {
         Admins vcontroller = new Admins();
         Entities.Size vsize = new Entities.Size();
         string errMsg = string.Empty;
         vsize = vcontroller.getby_size_ID(Request.QueryString["ID"], ref errMsg);
         lblsize.Text = vsize.Masize.ToString();
         txttensize.Text = vsize.Size1;
     }
     catch (Exception ex) { Response.Write(ex.Message); }
 }
 private void FillData()
 {
     try
     {
         Admins vcontroller = new Admins();
         Entities.SanPham vsanpham = new Entities.SanPham();
         Entities.Size vsize = new Entities.Size();
         Entities.SanPham_Size vsanpham_size = new Entities.SanPham_Size();
         string errMsg = string.Empty;
         string[] listid = Convert.ToString(Request.QueryString["ID"]).Split(new char[] { ',' });
         int masp = Convert.ToInt32(listid[0]);
         int masize = Convert.ToInt32(listid[1]);
         vsanpham = vcontroller.getby_sanpham(masp.ToString(), ref errMsg);
         lbltensanpham.Text = vsanpham.TenSP;
         vsize = vcontroller.getby_size_ID(masize.ToString(), ref errMsg);
         lblsize.Text = vsize.Size1;
         vsanpham_size = vcontroller.getby_sanpham_size(masp, masize, ref errMsg);
         txtsoluong.Text = vsanpham_size.Soluong.ToString();
     }
     catch (Exception ex) { Response.Write(ex.Message); }
 }
Ejemplo n.º 19
0
 private void SelectionChanged(Entities.Size size)
 {
     SelectedSize = size;
     UpdatePrice();
 }
        //Changed
        //Shifted code from Save Button to interface Save() method overriding
        public void Save()
        {
            currCattle = new Cattle();

            //string _name = textBoxName.Text;
            //string _fatherName = textBoxFatherName.Text;
            //int _salary = Convert.ToInt32(textBoxSalary.Text);

            #region Validation for valid employee data

            //Check if all text boxes are empty

            IEnumerable <TextBox>  textBoxcollection  = EntryGrid.Children.OfType <TextBox>();
            IEnumerable <ComboBox> comboBoxcollection = EntryGrid.Children.OfType <ComboBox>();

            foreach (TextBox box in textBoxcollection)
            {
                if (string.IsNullOrWhiteSpace(box.Text))
                {
                    if (box.Name == "textBoxDescription" ||
                        box.Name == "textBoxHeight" ||
                        box.Name == "textBoxLength" ||
                        box.Name == "textBoxWidth" ||
                        box.Name == "textBoxPrice" ||
                        box.Name == "textBoxWeight")
                    {
                        //ignore
                    }
                    else
                    {
                        MessageBox.Show("Kindly Fill all the boxes.");
                        return;
                    }
                }
            }

            foreach (ComboBox combobox in comboBoxcollection)
            {
                if (combobox.SelectedIndex == -1)
                {
                    MessageBox.Show("Kindly Select all the Drop-Downs");
                    return;
                }
            }

            //CheckTextBoxes(this);


            #endregion

            try
            {
                if (string.IsNullOrWhiteSpace(textBoxPrice.Text))
                {
                    currCattle.Price = 0;
                }
                else
                {
                    currCattle.Price = Convert.ToInt32(textBoxPrice.Text);
                }

                PhysicalAttributes physicalAttrib = new PhysicalAttributes();
                Entities.Size      currSize       = new Entities.Size();

                if (string.IsNullOrWhiteSpace(textBoxHeight.Text))
                {
                    currSize.Height = 0;
                }
                else
                {
                    currSize.Height = Convert.ToDouble(textBoxHeight.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxLength.Text))
                {
                    currSize.Length = 0;
                }
                else
                {
                    currSize.Length = Convert.ToDouble(textBoxLength.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxWidth.Text))
                {
                    currSize.Width = 0;
                }
                else
                {
                    currSize.Width = Convert.ToDouble(textBoxWidth.Text);
                }


                if (string.IsNullOrWhiteSpace(textBoxWeight.Text))
                {
                    physicalAttrib.Weight = 0;
                }
                else
                {
                    physicalAttrib.Weight = Convert.ToDouble(textBoxWeight.Text);
                }

                physicalAttrib.CurrentSize = currSize;

                currCattle.CurrPhysicalAttribs = physicalAttrib;

                currCattle.TagNo     = textBoxTagNo.Text;
                currCattle.BirthDate = datePickerDOB.SelectedDate.Value;

                //List<MasterTables> masterList = new List<MasterTables>();

                //masterList.Add((MasterTables)comboBoxBreed.SelectedItem);
                //masterList.Add((MasterTables)comboBoxGender.SelectedItem);
                //masterList.Add((MasterTables)comboBoxSource.SelectedItem);

                //AnimalBreed breed = new AnimalBreed();
                //breed = (AnimalBreed)masterList[0];

                //currCattle.Breed = breed;

                //currCattle.Breed = (AnimalBreed)comboBoxBreed.SelectedItem;
                //currCattle.Gender = (Gender)comboBoxGender.SelectedItem;
                //currCattle.Source = (AnimalSource)comboBoxSource.SelectedItem;

                //Only IDs needed for insertion

                currCattle.Breed    = new AnimalBreed();
                currCattle.Breed.ID = ((MasterTables)comboBoxBreed.SelectedItem).ID;


                currCattle.Gender = new Gender();

                string g = ((string)comboBoxGender.SelectedItem);

                currCattle.Gender.Description = g;


                currCattle.Source    = new AnimalSource();
                currCattle.Source.ID = ((MasterTables)comboBoxSource.SelectedItem).ID;


                currCattle.Type    = new AnimalType();
                currCattle.Type.ID = ((MasterTables)comboBoxAnimalType.SelectedItem).ID;


                currCattle.Status    = new AnimalStatus();
                currCattle.Status.ID = ((MasterTables)comboBoxStatus.SelectedItem).ID;


                currCattle.OtherDetails = textBoxDescription.Text;

                animalHandler.Add(currCattle);
            }
            catch (FormatException fexcept)
            {
                MessageBox.Show("Kindly Enter the field in correct (numeric) format. Error on " + fexcept.Source + " .", "Invalid Entry");
                return;
            }

            //Added - 01 Jan
            //For Name/Father name not containing numbers

            catch (ArgumentException aexcept)
            {
                MessageBox.Show(aexcept.Message, "Invalid Entry!");
                return;
            }


            //Clear all the TextBoxes

            foreach (TextBox textbox in textBoxcollection)
            {
                textbox.Text = "";
            }

            foreach (ComboBox combobox in comboBoxcollection)
            {
                combobox.SelectedIndex = -1;
            }
        }
        private List <Cattle> selectCattles(SqlCommand cmd)
        {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlConnection con         = cmd.Connection;
            List <Cattle> listCattles = new List <Cattle>();

            con.Open();
            using (con)
            {
                SqlDataReader dr = cmd.ExecuteReader();

                //              [TagNo]                     0
                //   ,[RegistrationDate]                    1
                //   ,[AnimalType]                          2
                //,at.Description                           3
                //   ,[Gender]                              4
                //ID                                            5
                //   ,[BirthDate]                       6
                //   ,[Weight]                      7
                //   ,[Height]                      8
                //   ,[Length]                      9
                //   ,[Width]                       10
                //   ,[Price]                           11
                //   ,[Source]                          12
                //,aso.Description                      13
                //   ,[Breed]                                   14
                //,ab.Description                          15
                //   ,[Status]                                16
                //,ast.Description                     17
                //   ,[OtherDetails]                 18

                //Added 31-March
                //ID as surrogate PK  and removed Gender FK

                if (dr.HasRows)
                {
                    listCattles = new List <Cattle>();
                    while (dr.Read())
                    {
                        AnimalBreed currCattleBreed = new AnimalBreed           //14,15
                        {
                            ID          = Convert.ToInt32(dr[14]),
                            Description = Convert.ToString(dr[15])
                        };

                        AnimalSource currCattleSource = new AnimalSource  //12,13
                        {
                            ID          = Convert.ToInt32(dr[12]),
                            Description = Convert.ToString(dr[13])
                        };
                        AnimalStatus currCattleStatus = new AnimalStatus        //16 , 17
                        {
                            ID          = Convert.ToInt32(dr[16]),
                            Description = Convert.ToString(dr[17])
                        };
                        AnimalType currCattleType = new AnimalType()            //2, 3
                        {
                            ID          = Convert.ToInt32(dr[2]),
                            Description = Convert.ToString(dr[3])
                        };
                        Gender currCattleGender = new Gender()                  //4 , 5
                        {
                            // ID = Convert.ToInt32(dr[4]),
                            Description = Convert.ToString(dr[4])
                        };

                        PhysicalAttributes currPhysicalAttribs = new PhysicalAttributes();

                        currPhysicalAttribs.Weight = Convert.ToDouble(dr[7]);   //7

                        Entities.Size currSize = new Entities.Size();           //TO avoid ambiguity among .Net's Size function

                        currSize.Height = Convert.ToDouble(dr[8]);
                        currSize.Length = Convert.ToDouble(dr[9]);
                        currSize.Width  = Convert.ToDouble(dr[10]);

                        currPhysicalAttribs.CurrentSize = currSize;

                        Cattle currCattle = new Cattle
                        {
                            ID               = Convert.ToInt32(dr[5]),
                            TagNo            = Convert.ToString(dr[0]),
                            RegistrationDate = Convert.ToDateTime(dr[1]),
                            BirthDate        = Convert.ToDateTime(dr[6]),
                            Price            = Convert.ToInt32(dr[11]),
                            OtherDetails     = Convert.ToString(dr[18])
                        };

                        currCattle.Breed  = currCattleBreed;
                        currCattle.Gender = currCattleGender;
                        currCattle.CurrPhysicalAttribs = currPhysicalAttribs;
                        currCattle.Source = currCattleSource;
                        currCattle.Status = currCattleStatus;
                        currCattle.Type   = currCattleType;

                        listCattles.Add(currCattle);
                    }
                }
            }
            return(listCattles);
        }
        public void Save()
        {
            currCalf = new Calf();

            //string _name = textBoxName.Text;
            //string _fatherName = textBoxFatherName.Text;
            //int _salary = Convert.ToInt32(textBoxSalary.Text);

            #region Validation for valid employee data

            //Check if all text boxes are empty

            IEnumerable <TextBox>  textBoxcollection  = EntryGrid.Children.OfType <TextBox>();
            IEnumerable <ComboBox> comboBoxcollection = EntryGrid.Children.OfType <ComboBox>();

            foreach (TextBox box in textBoxcollection)
            {
                if (string.IsNullOrWhiteSpace(box.Text))
                {
                    if (box.Name == "textBoxDescription" ||
                        box.Name == "textBoxHeight" ||
                        box.Name == "textBoxLength" ||
                        box.Name == "textBoxWidth" ||
                        box.Name == "textBoxPrice" ||
                        box.Name == "textBoxWeight")
                    {
                        //ignore
                    }
                    else
                    {
                        MessageBox.Show("Kindly Fill all the boxes.");
                        return;
                    }
                }
            }


            foreach (ComboBox combobox in comboBoxcollection)
            {
                if (combobox.SelectedIndex == -1)
                {
                    MessageBox.Show("Kindly Select all the Drop-Downs");
                    return;
                }
            }

            //Added Apr-02. Bug Fixed

            if (!datePickerDOB.SelectedDate.HasValue)
            {
                MessageBox.Show("Kindly Enter Date of Birth");
                return;
            }

            //CheckTextBoxes(this);


            #endregion

            try
            {
                currCalf.Price = 0;

                PhysicalAttributes physicalAttrib = new PhysicalAttributes();
                Entities.Size      currSize       = new Entities.Size();

                if (string.IsNullOrWhiteSpace(textBoxHeight.Text))
                {
                    currSize.Height = 0;
                }
                else
                {
                    currSize.Height = Convert.ToDouble(textBoxHeight.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxLength.Text))
                {
                    currSize.Length = 0;
                }
                else
                {
                    currSize.Length = Convert.ToDouble(textBoxLength.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxWidth.Text))
                {
                    currSize.Width = 0;
                }
                else
                {
                    currSize.Width = Convert.ToDouble(textBoxWidth.Text);
                }


                if (string.IsNullOrWhiteSpace(textBoxWeight.Text))
                {
                    physicalAttrib.Weight = 0;
                }
                else
                {
                    physicalAttrib.Weight = Convert.ToDouble(textBoxWeight.Text);
                }

                physicalAttrib.CurrentSize = currSize;

                currCalf.CurrPhysicalAttribs = physicalAttrib;

                currCalf.TagNo     = textBoxTagNo.Text;
                currCalf.BirthDate = datePickerDOB.SelectedDate.Value;

                //Only IDs needed for insertion

                currCalf.Breed    = new AnimalBreed();
                currCalf.Breed.ID = ((MasterTables)comboBoxBreed.SelectedItem).ID;


                currCalf.Gender             = new Gender();
                currCalf.Gender.Description = ((MasterTables)comboBoxGender.SelectedItem).Description;  //Modified 31 March

                currCalf.Source    = new AnimalSource();
                currCalf.Source.ID = ((MasterTables)comboBoxSource.SelectedItem).ID;


                currCalf.Type    = new AnimalType();
                currCalf.Type.ID = ((MasterTables)comboBoxAnimalType.SelectedItem).ID;

                //Commented on 01-Apr. No Status required for Calf
                //currCalf.Status = new AnimalStatus();
                //currCalf.Status.ID = ((MasterTables)comboBoxStatus.SelectedItem).ID;


                currCalf.OtherDetails = textBoxDescription.Text;

                Cattle mother = new Cattle();
                Cattle father = new Cattle();

                mother = (Cattle)comboBoxMother.SelectedItem;
                father = (Cattle)comboBoxFather.SelectedItem;

                currCalf.Mother = mother;
                currCalf.Father = father;

                //Added on Paril-02. Static Polymorphism for Calf Procedure
                //Whether it is for just calf
                //calf and mother
                //calf and father
                //or both

                if (mother.TagNo == "Other Farm")
                {
                    if (father.TagNo == "Artificial Insemnation")
                    {
                        animalHandler.Add(currCalf);
                    }
                    else
                    {
                        animalHandler.Add(currCalf, father.ID, 'N');
                    }
                }
                else
                {
                    if (father.TagNo == "Artificial Insemnation")
                    {
                        animalHandler.Add(currCalf, mother.ID, 'Y');
                    }
                    else
                    {
                        animalHandler.Add(currCalf, father.ID, mother.ID);
                    }
                }
            }

            catch (FormatException fexcept)
            {
                MessageBox.Show("Kindly Enter the field in correct (numeric) format. Error on " + fexcept.Source + " .", "Invalid Entry");
                return;
            }

            //Added - 01 Jan
            //For Name/Father name not containing numbers

            catch (ArgumentException aexcept)
            {
                MessageBox.Show(aexcept.Message, "Invalid Entry!");
                return;
            }


            //Clear all the TextBoxes

            foreach (TextBox textbox in textBoxcollection)
            {
                textbox.Text = "";
            }

            foreach (ComboBox combobox in comboBoxcollection)
            {
                combobox.SelectedIndex = -1;
            }

            datePickerDOB.SelectedDate = null;
        }