internal int InsertCompanyType(Inv_CompanyType aCompanyType) { try { _context.Inv_CompanyType.AddObject(aCompanyType); _context.SaveChanges(); return(1); } catch (Exception) { throw; } }
internal int UpdateCompanyType(Inv_CompanyType aCompanyType, int ID) { try { Inv_CompanyType CType = _context.Inv_CompanyType.First(x => x.CompanyType_Id == ID); CType.CompanyType = aCompanyType.CompanyType; _context.SaveChanges(); return(1); } catch (Exception) { throw; } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { Inv_CompanyType aCompanyType = new Inv_CompanyType(); aCompanyType.CompanyType = txtCopmayType.Text; if (btnSubmit.Text == "Submit") { int CompanyTypeCount = (from CType in _context.Inv_CompanyType where CType.CompanyType == aCompanyType.CompanyType select CType.CompanyType_Id).Count(); aCompanyType.EditUser = ((SessionUser)Session["SessionUser"]).UserId; aCompanyType.OCode = ((SessionUser)Session["SessionUser"]).OCode; aCompanyType.EditDate = DateTime.Now; if (CompanyTypeCount == 0) { int result = aCompanyTypeBLL.InsertCompanyType(aCompanyType); if (result == 1) { //lblMessage.Text = "Data Saved Successfully"; // lblMessage.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saved Successfully')", true); GetAllCompanyType(); txtCopmayType.Text = ""; } else { // lblMessage.Text = "Data Saving Failure"; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Saving Failure')", true); } } else { // lblMessage.Text = "Data Already Exist"; //lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Already Exist')", true); txtCopmayType.Focus(); txtCopmayType.Text = ""; btnSubmit.Text = "Submit"; } } else { int ID = Convert.ToInt32(hdfCompanyTypeID.Value); int result = aCompanyTypeBLL.UpdateCompanyType(aCompanyType, ID); if (result == 1) { // lblMessage.Text = "Data Updated Sucessfully"; // lblMessage.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Sucessfully')", true); GetAllCompanyType(); txtCopmayType.Text = ""; btnSubmit.Text = "Submit"; } else { //lblMessage.Text = "Data Updating failure"; //lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updating failure')", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }
internal int UpdateCompanyType(Inv_CompanyType aCompanyType, int ID) { return(aCompanyTypeDAL.UpdateCompanyType(aCompanyType, ID)); }