protected void DDLRecItemEntry_SelectedIndexChanged(object sender, EventArgs e) { try { TBBarcode.Enabled = true; DDLItemName.Enabled = true; TBSearchCode.Enabled = true; LBAddAllItem.Enabled = true; string ss = "SELECT Supplier FROM Receive_Master WHERE ID='" + DDLRecItemEntry.SelectedValue + "'"; DataSet ds = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, ss); if (ds.Tables[0].Rows.Count > 0) { DDLSupplier.ClearSelection(); DDLSupplier.Items.FindByValue(ds.Tables[0].Rows[0][0].ToString()).Selected = true; } string ss2 = "SELECT ID FROM Godown WHERE NGOID='" + DDLBusinessLocation.SelectedValue + "' AND ComID='" + Session["ComID"] + "'"; DataSet ds2 = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, ss2); if (ds2.Tables[0].Rows.Count > 0) { DDLGodown.ClearSelection(); DDLGodown.Items.FindByValue(ds2.Tables[0].Rows[0][0].ToString()).Selected = true; } string ss3 = "SELECT dbo.RawMaterial.ID,dbo.RawMaterial.Name FROM dbo.Receive_details INNER JOIN dbo.RawMaterial ON dbo.Receive_details.ItemID = dbo.RawMaterial.ID WHERE (dbo.Receive_details.rec_Id = '" + DDLRecItemEntry.SelectedValue + "')"; DataSet ds3 = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, ss3); if (ds3.Tables[0].Rows.Count > 0) { DDLItemName.Items.Clear(); DDLItemName.DataSource = ds3.Tables[0]; DDLItemName.DataTextField = "Name"; DDLItemName.DataValueField = "ID"; DDLItemName.DataBind(); DDLItemName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("-Select-", "0")); } } catch (Exception ex) { ShowMessage(ex.Message, MessageType.Error); } }
protected void CBAllowRIENumber_CheckedChanged(object sender, EventArgs e) { try { if (CBAllowRIENumber.Checked) { DDLRecItemEntry.ClearSelection(); DDLRecItemEntry.Dispose(); DDLRecItemEntry.Enabled = false; DDLGodown.ClearSelection(); DDLGodown.Enabled = true; DDLSupplier.ClearSelection(); DDLSupplier.Enabled = true; LBAddAllItem.Enabled = false; TBBarcode.Enabled = false; DDLItemName.Items.Clear(); DDLItemName.Enabled = false; TBSearchCode.Enabled = false; } else { DDLRecItemEntry.Enabled = true; DDLGodown.ClearSelection(); DDLGodown.Enabled = false; DDLSupplier.ClearSelection(); DDLSupplier.Enabled = false; LBAddAllItem.Enabled = false; TBBarcode.Enabled = false; DDLItemName.Items.Clear(); DDLItemName.Enabled = false; TBSearchCode.Enabled = false; } } catch (Exception ex) { ShowMessage(ex.Message, MessageType.Error); } }
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); } }