public ActionResult Save(tblConsignorDTO tblConsignorDTO)
 {
     if (ModelState.IsValid)
     {
         if (ConsignorBusinessLogic.CheckDuplicateCodeExists(tblConsignorDTO.Code, tblConsignorDTO.ConsignorId) == false)
         {
             tblConsignorDTO.CreationDate = DateTime.Now;
             var result = ConsignorBusinessLogic.Save(tblConsignorDTO);
             if (result > 0)
             {
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             ModelState.AddModelError("Code", "Code already exists.");
         }
     }
     tblConsignorDTO = FillDropDown(tblConsignorDTO);
     return(View(tblConsignorDTO));
 }
Exemple #2
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (IsFormValidate())
            {
                tblConsignorDTO tblConsignorDTO = new tblConsignorDTO();

                tblConsignorDTO.ConsignorId   = PartyId;
                tblConsignorDTO.ConsignorName = txtPartyName.Text;
                tblConsignorDTO.Code          = txtCode.Text;
                if (Convert.ToString(cbType.SelectedItem) == "Consignor")
                {
                    tblConsignorDTO.Type = 1;
                }
                else
                {
                    tblConsignorDTO.Type = 2;
                }
                tblConsignorDTO.Address     = txtAddress.Text;
                tblConsignorDTO.PhoneNo     = txtPhoneNo.Text;
                tblConsignorDTO.STNOCSTNO   = txtSTNOCSTNO.Text;
                tblConsignorDTO.TINNOVATNO  = txtTINNOVATNO.Text;
                tblConsignorDTO.Description = txtDescription.Text;
                if (ConsignorBusinessLogic.CheckDuplicateCodeExists(tblConsignorDTO.Code, tblConsignorDTO.ConsignorId) == false)
                {
                    tblConsignorDTO.CreationDate = DateTime.Now;
                    var result = ConsignorBusinessLogic.Save(tblConsignorDTO);
                    if (PartyId > 0)
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Code already exists.");
                }
            }
        }