internal int InsertYarnCount(LC_Yarn_Count objYarn) { try { _context.LC_Yarn_Count.AddObject(objYarn); _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
internal int UpdateYarnCount(LC_Yarn_Count objYarn, int yarnId) { try { LC_Yarn_Count obj = _context.LC_Yarn_Count.First(x => x.YarnCount_ID == yarnId); obj.Yarn_Count = objYarn.Yarn_Count; obj.Status = objYarn.Status; obj.EDIT_USER = objYarn.EDIT_USER; obj.EDIT_DATE = objYarn.EDIT_DATE; _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
private bool IsExist(string yarnCount) { try { ERPSSL_MerchandisingEntities _context = new ERPSSL_MerchandisingEntities(); LC_Yarn_Count objYarn = new LC_Yarn_Count(); bool status = false; int count = (from yarn in _context.LC_Yarn_Count where yarn.Yarn_Count == yarnCount select yarn.YarnCount_ID).Count(); if (count == 0) { status = true; } return(status); } catch (Exception) { throw; } }
protected void btnYarnSubmit_Click(object sender, EventArgs e) { try { if (txtYarnCount.Text == "") { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input Yarn Count!')", true); } else { LC_Yarn_Count objyarn = new LC_Yarn_Count(); objyarn.OCODE = ((SessionUser)Session["SessionUser"]).OCode; objyarn.Yarn_Count = txtYarnCount.Text; objyarn.Status = drpStatus.SelectedItem.Text; if (btnYarnSubmit.Text == "Submit") { if (IsExist(objyarn.Yarn_Count)) { objyarn.CreateUser = ((SessionUser)Session["SessionUser"]).UserId; objyarn.CreateDate = DateTime.Now; int result = obj_Yarn_BLL.InsertYarnCount(objyarn); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Save successfully!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Already Exists!')", true); } } else { if (hidYarnName.Value != txtYarnCount.Text) { if (IsExist(objyarn.Yarn_Count)) { objyarn.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; objyarn.EDIT_DATE = DateTime.Now; int yarnId = Convert.ToInt32(hidYarnId.Value); int result = obj_Yarn_BLL.UpdateYarnCount(objyarn, yarnId); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Update successfully!')", true); } } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Already Exists!')", true); } } else { objyarn.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; objyarn.EDIT_DATE = DateTime.Now; int yarnId = Convert.ToInt32(hidYarnId.Value); int result = obj_Yarn_BLL.UpdateYarnCount(objyarn, yarnId); if (result == 1) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Update successfully!')", true); } } } GetYarnCount(); ClearYarnCountUi(); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }
internal int UpdateYarnCount(LC_Yarn_Count objYarn, int yarnId) { return(obj_DAL.UpdateYarnCount(objYarn, yarnId)); }
internal int InsertYarnCount(LC_Yarn_Count objYarn) { return(obj_DAL.InsertYarnCount(objYarn)); }