//Bind Item Unit #region [Bind Item Unit Grid] public DataSet BindUnitGrid_DL(EWA_Unit objEWA) { DataSet ds = new DataSet(); try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "SelectData"; prmList[2] = "OrgId"; prmList[3] = objEWA.OrgId.ToString(); ds = ObjHelper.FillControl(prmList, "SP_Unit"); if (ds.Tables[0].Rows.Count > 0) { return(ds); } else { DataTable dt = new DataTable(); dt.Columns.Add("UnitName"); dt.Rows.Add(); dt.Rows.Add(); dt.Rows.Add(); //return dsCode; } return(ds); } catch (Exception exp) { throw exp; } }
//Perform Action #region [Perform Actions On Item Unit] public int UnitAction_DL(EWA_Unit objEWA) { try { cmd = new SqlCommand("SP_Unit", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", objEWA.Action); cmd.Parameters.AddWithValue("@UnitId", objEWA.UnitId); cmd.Parameters.AddWithValue("@UnitName", objEWA.UnitName); cmd.Parameters.AddWithValue("@OrgId", objEWA.OrgId); cmd.Parameters.AddWithValue("@UserId", objEWA.UserId); cmd.Parameters.AddWithValue("@IsActive", objEWA.IsActive); con.Open(); int flag = cmd.ExecuteNonQuery(); return(flag); } catch (Exception ex) { int err = ((System.Data.SqlClient.SqlException)(ex)).Number; if (err == 547 && objEWA.Action == "Delete") { throw new SystemException("Record is in use !!!"); } else { throw ex; } } finally { con.Close(); cmd.Dispose(); } }
//To Check Duplicate Item Unit #region [Check Duplicate Item Unit] public int CheckDuplicateUnit_DL(EWA_Unit objEWA) { try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "CheckData"; prmList[2] = "@UnitName"; prmList[3] = objEWA.UnitName; DataSet dsData = ObjHelper.FillControl(prmList, "SP_Unit"); if (dsData.Tables[0].Rows.Count > 0) { return(1); } else { return(0); } } catch (Exception exp) { throw exp; } }
//Check Duplicate Item Unit #region [Check Duplicate Item Unit] public int CheckDuplicateUnit_BL(EWA_Unit objEWA) { try { DL_Unit objDL = new DL_Unit(); int i = objDL.CheckDuplicateUnit_DL(objEWA); return(i); } catch (Exception exp) { throw exp; } }
//Item UnitGrid Bind #region [Item UnitGrid Bind] public DataSet UnitGridBind_BL(EWA_Unit objEWA) { try { DL_Unit objDL = new DL_Unit(); DataSet ds = objDL.BindUnitGrid_DL(objEWA); return(ds); } catch (Exception exp) { throw exp; } }
//Action Performed #region [ActionPerformed For ItemUnit] public int UnitAction_BL(EWA_Unit objEWA) { try { DL_Unit objDL = new DL_Unit(); int flag = objDL.UnitAction_DL(objEWA); return(flag); } catch (Exception exp) { throw exp; } }
//Check Data #region [Check Data] private int CheckData() { int i = 0; try { EWA_Unit objEWA = new EWA_Unit(); objEWA.UnitName = txtUnitName.Text.Trim(); i = objBL.CheckDuplicateUnit_BL(objEWA); return(i); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); return(0); } }
//Save Data #region SaveData protected void btnSave_Click(object sender, EventArgs e) { BL_Unit objBL = new BL_Unit(); EWA_Unit objEWA = new EWA_Unit(); try { lock (this) { if (txtUnitName.Text == "") { msgBox.ShowMessage("Please Enter Unit Name !!!", "Information", UserControls.MessageBox.MessageStyle.Information); } else { //ViewState["DocumentId"] = 0; int chk = CheckData(); if (chk > 0) { msgBox.ShowMessage("Record Allready Exist !!!", "Information", UserControls.MessageBox.MessageStyle.Information); } else { Action("Save"); GrdUnitBind(); LoadForm(); } } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }