//To Check Duplicate Supplier #region [Check Duplicate Supplier] public int CheckDuplicateSupplier_DL(EWA_Supplier objEWA) { try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "CheckData"; prmList[2] = "@SupplierName"; prmList[3] = objEWA.SupplierName; DataSet dsData = ObjHelper.FillControl(prmList, "SP_Supplier"); if (dsData.Tables[0].Rows.Count > 0) { return(1); } else { return(0); } } catch (Exception exp) { throw exp; } }
//SupplierCategory #region [SupplierCategory Grid Bind] private void BindSupplierGrid() { try { EWA_Supplier objEWA = new EWA_Supplier(); objEWA.OrgId = orgId; DataSet ds = objBL.BindSupplierGrid_BL(objEWA); if (ds.Tables[0].Rows.Count == 0 || ds == null) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); GrdSupplier.DataSource = ds; GrdSupplier.DataBind(); int columncount = GrdSupplier.Rows[0].Cells.Count; GrdSupplier.Rows[0].Cells.Clear(); GrdSupplier.Rows[0].Cells.Add(new TableCell()); GrdSupplier.Rows[0].Cells[0].ColumnSpan = columncount; GrdSupplier.Rows[0].Cells[0].Text = "No Records Found"; } else { GrdSupplier.DataSource = ds; GrdSupplier.DataBind(); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//Bind Supplier Category #region [Bind Supplier Grid] public DataSet BindSupplierGrid_DL(EWA_Supplier objEWA) { DataSet ds = new DataSet(); try { prmList = new string[4]; prmList[0] = "@Action"; prmList[1] = "SelectData"; prmList[2] = "@OrgId"; prmList[3] = Convert.ToString(objEWA.OrgId); ds = ObjHelper.FillControl(prmList, "SP_Supplier"); if (ds.Tables[0].Rows.Count > 0) { return(ds); } else { DataTable dt = new DataTable(); dt.Columns.Add("SupplierName"); dt.Rows.Add(); dt.Rows.Add(); dt.Rows.Add(); //return dsCode; } return(ds); } catch (Exception exp) { throw exp; } }
//Check Duplicate Supplier #region [Check Duplicate Supplier] public int CheckDuplicateSupplier_BL(EWA_Supplier objEWA) { try { DL_Supplier objDL = new DL_Supplier(); int i = objDL.CheckDuplicateSupplier_DL(objEWA); return(i); } catch (Exception exp) { throw exp; } }
//Supplier Grid Bind #region [Supplier Grid Bind] public DataSet BindSupplierGrid_BL(EWA_Supplier objEWA) { try { DL_Supplier objDL = new DL_Supplier(); DataSet ds = objDL.BindSupplierGrid_DL(objEWA); return(ds); } catch (Exception exp) { throw exp; } }
//Action Performed #region [ActionPerformed For Supplier ] public int SupplierAction_BL(EWA_Supplier objEWA, DataTable dt) { try { DL_Supplier objDL = new DL_Supplier(); int flag = objDL.SupplierAction_DL(objEWA, dt); return(flag); } catch (Exception) { throw; } }
//Perform Action on Supplier Table #region [Perform Actions On Supplier] public int SupplierAction_DL(EWA_Supplier objEWA, DataTable dt) { try { cmd = new SqlCommand("SP_Supplier", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", objEWA.Action); cmd.Parameters.AddWithValue("@SupplierId", objEWA.SupplierId); cmd.Parameters.AddWithValue("@SupplierName", objEWA.SupplierName); cmd.Parameters.AddWithValue("@MobileNo", objEWA.MobileNo); cmd.Parameters.AddWithValue("@PhoneNo", objEWA.PhoneNo); cmd.Parameters.AddWithValue("@FaxNo", objEWA.FaxNo); cmd.Parameters.AddWithValue("@EmailId", objEWA.EmailId); cmd.Parameters.AddWithValue("@Website", objEWA.Website); cmd.Parameters.AddWithValue("@Address", objEWA.Address); cmd.Parameters.AddWithValue("@OrgId", objEWA.OrgId); cmd.Parameters.AddWithValue("@UserId", objEWA.UserId); cmd.Parameters.AddWithValue("@IsActive", objEWA.IsActive); SqlParameter tblvaluetype = cmd.Parameters.AddWithValue("@SupplierItem", dt); //Passing table value parameter tblvaluetype.SqlDbType = SqlDbType.Structured; con.Open(); sqlTransaction = con.BeginTransaction(); cmd.Transaction = sqlTransaction; int flag = cmd.ExecuteNonQuery(); sqlTransaction.Commit(); 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(); } }
//Check Data #region [Check Data] private int CheckData() { int i = 0; try { EWA_Supplier objEWA = new EWA_Supplier(); BL_Supplier objBL = new BL_Supplier(); objEWA.SupplierName = txtSupplierName.Text.Trim(); i = objBL.CheckDuplicateSupplier_BL(objEWA); return(i); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); return(0); } }
//SupplierCategory Link #region SupplierSupplierLinkButtonClick protected void lnkBtnSupplierName_Click(object sender, EventArgs e) { try { lock (this) { BL_Supplier objBL = new BL_Supplier(); EWA_Supplier objEWA = new EWA_Supplier(); LinkButton lnkBtnId = (LinkButton)sender; GridViewRow grdrow = lnkBtnId.NamingContainer as GridViewRow; // lnkBtnId = (LinkButton)grdrow.Cells[0].FindControl("SupplierId"); ViewState["SupplierId"] = GrdSupplier.DataKeys[grdrow.RowIndex].Value.ToString(); objEWA.SupplierId = Convert.ToInt32(ViewState["SupplierId"]); objEWA.OrgId = orgId; DataSet ds = objBL.BindSupplierData_BL(objEWA); txtSupplierName.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["SupplierName"].ToString(); //ddlCategory.SelectedValue = GrdSupplier.DataKeys[grdrow.RowIndex].Values["CategoryId"].ToString(); txtMobileNo.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["MobileNo"].ToString(); txtPhoneNo.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["PhoneNo"].ToString(); txtFaxNo.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["FaxNo"].ToString(); txtEmailId.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["EmailId"].ToString(); txtWebsite.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["Website"].ToString(); txtAddress.Text = GrdSupplier.DataKeys[grdrow.RowIndex].Values["Address"].ToString(); if (ds.Tables[1].Rows.Count >= 0) { ViewState["SuppItem"] = ds; GrdItem.DataSource = ds.Tables[2]; GrdItem.DataBind(); } else { BindItemGrid(); } callUpdate(); } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }