protected void btnSave_Click(object sender, EventArgs e) { try { Com_Buyer_Setup _buyerobj = new Com_Buyer_Setup(); _buyerobj.Type = drpBuyerType.SelectedValue.ToString(); _buyerobj.Buyer_Name = txtbxBuyerName.Text.Trim(); _buyerobj.Contact_Person = txtbxContractPerson.Text.Trim(); _buyerobj.Mobile = txtbxCellNo.Text.Trim(); _buyerobj.Phone = txtbxPhone.Text.Trim(); _buyerobj.Email = txtEmail.Text; _buyerobj.Counter = drpCountery.SelectedValue.ToString().Trim(); _buyerobj.Address = txtbxAddress.Text.Trim(); _buyerobj.Buyer_Address = txtBuyerAddress.Text; _buyerobj.Land_Address = txtLandAddress.Text; _buyerobj.Sea_Address = txtSeaAddress.Text; _buyerobj.Delivery_Address = txtDeliveryAddress.Text.Trim(); _buyerobj.Destination_Address = txtDestinationAddress.Text.Trim(); _buyerobj.OCODE = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); _buyerobj.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; _buyerobj.EDIT_DATE = DateTime.Now; _buyerobj.Consignee = txtConsignee.Text; _buyerobj.NotifyParty = txtNotifyParty.Text; if (drpSataus.SelectedItem.ToString() == "True") { _buyerobj.Status = true; } else { _buyerobj.Status = false; } if (btnSave.Text != "Update") { int result = _Buyerbll.Save(_buyerobj); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Buyer Saved Successfully')", true); } } else { _buyerobj.Buyer_ID = Convert.ToInt16(hidBueyId.Value); int result = _Buyerbll.Update(_buyerobj); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Buyer Updated Successfully')", true); } } GetBuyerList(); ClearAllController(); } catch (Exception) { throw; } }
protected void btnSave_Click(object sender, EventArgs e) { try { int BuyDept = 0; Com_Buyer_Setup _buyerobj = new Com_Buyer_Setup(); LC_BuyerDepartment _LC_BuyerDepartment = new LC_BuyerDepartment(); if (chkBuyingDepartment.Checked == true) { int count = (from Bd in _Context.LC_BuyerDepartment where Bd.BuyerDepartment_Name == _LC_BuyerDepartment.BuyerDepartment_Name select Bd.BuyerDepartment_Name).Count(); if (count > 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Buyer Department already Exist')", true); return; } _LC_BuyerDepartment.BuyerDepartment_Name = txtBuyingDepartment.Text; _LC_BuyerDepartment.Create_Date = DateTime.Today; _LC_BuyerDepartment.Create_User = ((SessionUser)Session["SessionUser"]).UserId; _LC_BuyerDepartment.OCode = ((SessionUser)Session["SessionUser"]).OCode; int result = _Buyerbll.AddBuyerDepartment(_LC_BuyerDepartment); BuyDept = result; } if (chkPrincipalName.Checked == true) { _buyerobj.PrincipalName = txtPrincipalName.Text; } else { _buyerobj.PrincipalName = ddlPrincipalName.SelectedValue; } _buyerobj.Address = txtbxAddress.Text; _buyerobj.Country = ddlCountry.SelectedItem.Text; if (chkBuyer.Checked == true) { _buyerobj.Buyer_Name = txtBuyer.Text; } else { _buyerobj.Buyer_Name = ddlBuyer.SelectedValue; } if (chkBuyingDepartment.Checked == true) { _buyerobj.BuyingDepartmentId = BuyDept; } else { _buyerobj.BuyingDepartmentId = Convert.ToInt32(ddlBuyingDepartment.SelectedValue); } _buyerobj.Phone = txtbxPhone.Text.Trim(); _buyerobj.Email = txtEmail.Text; _buyerobj.Delivery_Address = txtDeliveryAddress.Text.Trim(); _buyerobj.Destination_Address = txtDestinationAddress.Text.Trim(); _buyerobj.OCODE = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); _buyerobj.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; _buyerobj.EDIT_DATE = DateTime.Now; _buyerobj.Consignee = txtConsignee.Text; _buyerobj.NotifyParty = txtNotifyParty.Text; if (drpSataus.SelectedItem.ToString() == "True") { _buyerobj.Status = true; } else { _buyerobj.Status = false; } if (btnSave.Text != "Update") { int result = _Buyerbll.Save(_buyerobj); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Buyer Saved Successfully')", true); } } else { _buyerobj.Buyer_ID = Convert.ToInt16(hidBueyId.Value); int result = _Buyerbll.Update(_buyerobj); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Buyer Updated Successfully')", true); } } GetBuyerList(); ClearAllController(); } catch (Exception) { throw; } }