private void BindCategory() { SqlParameter[] arrParam = new SqlParameter[1]; arrParam[0] = new SqlParameter("@Action", "SELECT"); DataSet DSCat = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_CatMaster_CRUD", arrParam); if (DSCat.Tables[0].Rows.Count > 0) { DDLCat.DataSource = DSCat.Tables[0]; DDLCat.DataTextField = "CatName"; DDLCat.DataValueField = "ID"; DDLCat.DataBind(); DDLCat.Items.Insert(0, new ListItem("Select", "0")); } }
private void ClearUserForm() { TBName.Text = string.Empty; TBProductCode.Text = string.Empty; TBHSN.Text = string.Empty; TBBarcode.Text = string.Empty; TBUOM.Text = string.Empty; DDLCat.ClearSelection(); TBOpeningStock.Text = string.Empty; TBOSDate.Text = string.Empty; TBReorderQty.Text = string.Empty; TBBinLocation.Text = string.Empty; TBMFGDate.Text = string.Empty; TBExpireDate.Text = string.Empty; TBDescription.Text = string.Empty; TBPurPrice.Text = string.Empty; TBSalePrice.Text = string.Empty; ImgLogo.ImageUrl = string.Empty; btnSubmit.Text = "Submit"; }
protected void GVRawMaterial_RowCommand(object sender, GridViewCommandEventArgs e) { try { int recordId = Convert.ToInt32(e.CommandArgument); Session["RecordId"] = recordId; #region For Edit Record if (e.CommandName == "EditRecord") { SqlParameter[] arrParam = new SqlParameter[2]; arrParam[0] = new SqlParameter("@Action", "SELECT_ByID"); arrParam[1] = new SqlParameter("@ID", recordId); DataSet DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_RawMaterial_CRUD", arrParam); DataTable DTRecords = DSRecords.Tables[0]; if (DTRecords.Rows.Count > 0) { MVRawMatrial.ActiveViewIndex = 1; TBName.Text = DTRecords.Rows[0]["Name"].ToString(); TBProductCode.Text = DTRecords.Rows[0]["ProductCode"].ToString(); TBHSN.Text = DTRecords.Rows[0]["HSNCode"].ToString(); TBBarcode.Text = DTRecords.Rows[0]["Barcode"].ToString(); TBUOM.Text = DTRecords.Rows[0]["UOM"].ToString(); BindCategory(); DDLCat.ClearSelection(); DDLCat.Items.FindByValue(DTRecords.Rows[0]["Category"].ToString()).Selected = true; BindSupplier(); DDLSupplier.ClearSelection(); DDLSupplier.Items.FindByValue(DTRecords.Rows[0]["Supplier"].ToString()).Selected = true; TBDescription.Text = DTRecords.Rows[0]["Description"].ToString(); TBPurPrice.Text = DTRecords.Rows[0]["PurPrice"].ToString(); TBSalePrice.Text = DTRecords.Rows[0]["SalePrice"].ToString(); int GodownID = GetGodownID(); string Query = "SELECT * FROM ItemStock WHERE ItemID='" + recordId + "' AND GodownID='" + GodownID + "'"; DataSet DSStockItem = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, Query); if (DSStockItem.Tables[0].Rows.Count > 0) { TBOpeningStock.Text = DSStockItem.Tables[0].Rows[0]["OpeningStock"].ToString(); TBOSDate.Text = DSStockItem.Tables[0].Rows[0]["OSDate"].ToString(); TBReorderQty.Text = DSStockItem.Tables[0].Rows[0]["ReorderQty"].ToString(); TBBinLocation.Text = DSStockItem.Tables[0].Rows[0]["BinLocation"].ToString(); } TBMFGDate.Text = DTRecords.Rows[0]["MFGDate"].ToString(); TBExpireDate.Text = DTRecords.Rows[0]["ExpireDate"].ToString(); ImgLogo.ImageUrl = DTRecords.Rows[0]["Image"].ToString(); btnSubmit.Text = "Update"; } } #endregion #region For Delete Record if (e.CommandName == "DeleteRecord") { // Delete Image From Folder SqlParameter[] arrParamDel = new SqlParameter[2]; arrParamDel[0] = new SqlParameter("@Action", "SELECT_ByID"); arrParamDel[1] = new SqlParameter("@ID", recordId); DataSet DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_RawMaterial_CRUD", arrParamDel); if (DSRecords.Tables[0].Rows[0]["Image"].ToString() != "" && DSRecords.Tables[0].Rows[0]["Image"].ToString() != "~/AdminImages/noimg.png") { File.Delete(Server.MapPath(DSRecords.Tables[0].Rows[0]["Image"].ToString())); } SqlParameter[] arrParam = new SqlParameter[2]; arrParam[0] = new SqlParameter("@Action", "DELETE"); arrParam[1] = new SqlParameter("@ID", recordId); int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_RawMaterial_CRUD", arrParam); } #endregion #region For Change Status if (e.CommandName == "ChangeStatus") { SqlParameter[] arrParam = new SqlParameter[2]; arrParam[0] = new SqlParameter("@Action", "SELECT_ByID"); arrParam[1] = new SqlParameter("@ID", recordId); DataSet DSRecords = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.StoredProcedure, "SP_RawMaterial_CRUD", arrParam); DataTable DTRecords = DSRecords.Tables[0]; if (DTRecords.Rows.Count > 0) { #region Change Status True To False if (DTRecords.Rows[0]["Status"].ToString() == "True") { SqlParameter[] arrParam2 = new SqlParameter[3]; arrParam2[0] = new SqlParameter("@Action", "UPDATE_Status"); arrParam2[1] = new SqlParameter("@Status", false); arrParam2[2] = new SqlParameter("@ID", recordId); int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_RawMaterial_CRUD", arrParam2); } #endregion #region Change Status False TO True if (DTRecords.Rows[0]["Status"].ToString() == "False") { SqlParameter[] arrParam2 = new SqlParameter[3]; arrParam2[0] = new SqlParameter("@Action", "UPDATE_Status"); arrParam2[1] = new SqlParameter("@Status", true); arrParam2[2] = new SqlParameter("@ID", recordId); int Result = SqlHelper.ExecuteNonQuery(Connection.connect(), CommandType.StoredProcedure, "SP_RawMaterial_CRUD", arrParam2); } #endregion } } #endregion BindGVRawMaterial(); } catch (Exception ex) { ShowMessage(ex.Message, MessageType.Error); } }