public static int update(ModelSalesGoods model) { string strSQL = @" UPDATE sales_goods SET id_contract = @id_contract, name_product = @name_product, type = @type, name_factory = @name_factory, unit = @unit, amount = @amount, price_unit = @price_unit, price_total = @price_total, batch_number = @batch_number, validity_period = @validity_period, approval_number = @approval_number, comment = @comment, photo_urls = @photo_urls, id_admin = @id_admin, time_add = @time_add, amount_stock = @amount_stock WHERE id = @id "; MySqlParameter[] aryParams = new MySqlParameter[17]; aryParams[0] = new MySqlParameter("@id_contract", model.id_contract); aryParams[1] = new MySqlParameter("@name_product", model.name_product); aryParams[2] = new MySqlParameter("@type", model.type); aryParams[3] = new MySqlParameter("@name_factory", model.name_factory); aryParams[4] = new MySqlParameter("@unit", model.unit); aryParams[5] = new MySqlParameter("@amount", model.amount); aryParams[6] = new MySqlParameter("@price_unit", model.price_unit); aryParams[7] = new MySqlParameter("@price_total", model.price_total); aryParams[8] = new MySqlParameter("@batch_number", model.batch_number); aryParams[9] = new MySqlParameter("@validity_period", model.validity_period); aryParams[10] = new MySqlParameter("@approval_number", model.approval_number); aryParams[11] = new MySqlParameter("@comment", model.comment); aryParams[12] = new MySqlParameter("@photo_urls", model.photo_urls); aryParams[13] = new MySqlParameter("@id_admin", model.id_admin); aryParams[14] = new MySqlParameter("@time_add", model.time_add); aryParams[15] = new MySqlParameter("@amount_stock", model.amount_stock); aryParams[16] = new MySqlParameter("@id", model.id); return(HelperMySql.ExecuteNonQuery(strSQL, aryParams)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_update"); ViewState["AdminId"] = intAdminId; ViewState["ContractId"] = HelperUtility.getQueryInt("cid"); ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage"); ViewState["Page"] = HelperUtility.getQueryInt("page"); int intId = HelperUtility.getQueryInt("id"); ViewState["Id"] = intId; ModelSalesGoods model = BllSalesGoods.getById(intId); tbProductName.Value = model.name_product; tbType.Text = model.type; tbFactoryName.Value = model.name_factory; tbUnit.Text = model.unit; tbAmount.Text = model.amount.ToString(); tbPriceUnit.Text = model.price_unit.ToString(); tbBatchNumber.Value = model.batch_number; tbValidityPeriod.Value = model.validity_period.ToString(); tbComment.Text = model.comment; // 设置照片 string strPhotoUrls = model.photo_urls; if (!"".Equals(strPhotoUrls)) { string strImgUrl, strJS; List <string> listPhotoUrls = strPhotoUrls.Split(',').ToList(); intPhotoAmounts = listPhotoUrls.Count; for (int i = 0; i < intPhotoAmounts; i++) { strImgUrl = listPhotoUrls[i]; strJS = "<div id=\"img-" + i + "\" class=\"wrapper-photo-show\">"; strJS += "<img width=\"100\" height=\"100\" src=\"" + strImgUrl + "\" /><br />"; strJS += "<input type=\"button\" id=\"btnDelPhoto\" class=\"btn btn-sm btn-warning\"" + " onclick=\"delPhoto(" + i + ")\" value=\"删除\" /></div>"; ltrShowPhoto.Text += strJS; } } tbPhotoUrls.Value = strPhotoUrls; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_show"); int intId = HelperUtility.getQueryInt("id"); ModelSalesGoods model = BllSalesGoods.getById(intId); if (model == null) { HelperUtility.showAlert("没有找到此货品!", "list.aspx"); } lblProductName.Text = model.name_product; lblType.Text = model.type; lblFactoryName.Text = model.name_factory; lblUnit.Text = model.unit; lblAmount.Text = model.amount.ToString(); lblPriceUnit.Text = model.price_unit.ToString("C"); lblPriceTotal.Text = model.price_total.ToString("C"); lblBatchNumber.Text = model.batch_number; lblValidityPeriod.Text = model.validity_period.ToString(); lblComment.Text = model.comment; // 设置照片 string strPhotoUrls = model.photo_urls; if (!"".Equals(strPhotoUrls)) { string strImgUrl, strJS; List <string> listPhotoUrls = strPhotoUrls.Split(',').ToList(); for (int i = 0; i < listPhotoUrls.Count; i++) { strImgUrl = listPhotoUrls[i]; strJS = "<div id=\"img-" + i + "\" class=\"wrapper-photo-show\">"; strJS += "<a href=\"" + strImgUrl + "\">"; strJS += "<img width=\"100\" height=\"100\" src=\"" + strImgUrl + "\" />"; strJS += "</a></div>"; ltrShowPhoto.Text += strJS; } } } }
protected void btnEdit_Click(object sender, EventArgs e) { string strUrl; // 验证权限 if (!HelperUtility.hasPurviewOP("SalesGoods_update")) { HelperUtility.showAlert("没有操作权限", "/BackManager/home.aspx"); } // 验证表单 string strMsgError = ""; int intId = Convert.ToInt32(ViewState["Id"]); string strProductName = tbProductName.Value.Trim(); if ("".Equals(strProductName)) { strMsgError += "货品名称不能为空!"; } string strType = tbType.Text.Trim(); string strFactoryName = tbFactoryName.Value.Trim(); string strUnit = tbUnit.Text.Trim(); decimal dcmAmount = Convert.ToDecimal(tbAmount.Text.Trim()); decimal dcmPriceUnit = Convert.ToDecimal(tbPriceUnit.Text.Trim()); decimal dcmPriceTotal = dcmAmount * dcmPriceUnit; string strBatchNumber = tbBatchNumber.Value.Trim(); if ("".Equals(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间不能为空!"; } if (!HelperUtility.isDateType(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间格式不正确!"; } DateTime dateValidityPeriod = Convert.ToDateTime(tbValidityPeriod.Value.Trim()); string strApprovalNumber = ""; string strComment = tbComment.Text.Trim(); if (strComment.Length > 1000) { strMsgError += "备注信息不能超过500个字数!"; } string strPhotoUrls = tbPhotoUrls.Value; if (strPhotoUrls.EndsWith(",")) { strPhotoUrls = strPhotoUrls.Substring(0, strPhotoUrls.Length - 1); } if (!"".Equals(strMsgError)) { HelperUtility.showAlert(strMsgError, "edit.aspx?id=" + intId); return; } // 验证完毕,提交数据 ModelSalesGoods model = BllSalesGoods.getById(intId); model.name_product = strProductName; model.type = strType; model.name_factory = strFactoryName; model.unit = strUnit; model.amount = dcmAmount; model.price_unit = dcmPriceUnit; model.price_total = dcmPriceTotal; model.batch_number = strBatchNumber; model.validity_period = dateValidityPeriod; model.approval_number = strApprovalNumber; model.comment = strComment; model.photo_urls = strPhotoUrls; model.amount_stock = dcmAmount; BllSalesGoods.update(model); strUrl = "list.aspx" + "?cid=" + ViewState["ContractId"] + "&cpage=" + ViewState["ContractPage"] + "&page=" + ViewState["Page"]; HelperUtility.showAlert("修改成功!", strUrl); }
public static int add(ModelSalesGoods model) { string strSQL = @" INSERT INTO sales_goods ( id_contract, name_product, type, name_factory, unit, amount, price_unit, price_total, batch_number, validity_period, approval_number, comment, photo_urls, id_admin, time_add, amount_stock ) VALUES ( @id_contract, @name_product, @type, @name_factory, @unit, @amount, @price_unit, @price_total, @batch_number, @validity_period, @approval_number, @comment, @photo_urls, @id_admin, @time_add, @amount_stock )"; MySqlParameter[] aryParams = new MySqlParameter[16]; aryParams[0] = new MySqlParameter("@id_contract", model.id_contract); aryParams[1] = new MySqlParameter("@name_product", model.name_product); aryParams[2] = new MySqlParameter("@type", model.type); aryParams[3] = new MySqlParameter("@name_factory", model.name_factory); aryParams[4] = new MySqlParameter("@unit", model.unit); aryParams[5] = new MySqlParameter("@amount", model.amount); aryParams[6] = new MySqlParameter("@price_unit", model.price_unit); aryParams[7] = new MySqlParameter("@price_total", model.price_total); aryParams[8] = new MySqlParameter("@batch_number", model.batch_number); aryParams[9] = new MySqlParameter("@validity_period", model.validity_period); aryParams[10] = new MySqlParameter("@approval_number", model.approval_number); aryParams[11] = new MySqlParameter("@comment", model.comment); aryParams[12] = new MySqlParameter("@photo_urls", model.photo_urls); aryParams[13] = new MySqlParameter("@id_admin", model.id_admin); aryParams[14] = new MySqlParameter("@time_add", model.time_add); aryParams[15] = new MySqlParameter("@amount_stock", model.amount_stock); if (HelperMySql.ExecuteNonQuery(strSQL, aryParams) > 0) { strSQL = "SELECT MAX(id) FROM sales_goods"; object objReturn = HelperMySql.ExecuteScalar(strSQL); return(objReturn == null ? 0 : Convert.ToInt32(objReturn)); } else { return(0); } }
protected void btnAdd_Click(object sender, EventArgs e) { string strUrl; // 验证权限 if (!HelperUtility.hasPurviewOP("SalesGoods_add")) { HelperUtility.showAlert("没有操作权限", "/BackManager/home.aspx"); } // 验证表单 string strMsgError = ""; int intContractId = (int)ViewState["ContractId"]; string strProductName = tbProductName.Value.Trim(); if ("".Equals(strProductName)) { strMsgError += "货品名称不能为空!"; } string strType = tbType.Text.Trim(); string strFactoryName = tbFactoryName.Value.Trim(); string strUnit = tbUnit.Text.Trim(); decimal dcmAmount = Convert.ToDecimal(tbAmount.Text.Trim()); decimal dcmPriceUnit = Convert.ToDecimal(tbPriceUnit.Text.Trim()); decimal dcmPriceTotal = dcmAmount * dcmPriceUnit; string strBatchNumber = tbBatchNumber.Value.Trim(); if ("".Equals(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间不能为空!"; } if (!HelperUtility.isDateType(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间格式不正确!"; } DateTime dateValidityPeriod = Convert.ToDateTime(tbValidityPeriod.Value.Trim()); string strApprovalNumber = ""; string strComment = tbComment.Text.Trim(); if (strComment.Length > 1000) { strMsgError += "备注信息不能超过500个字数!"; } string strPhotoUrls = tbPhotoUrls.Value; if (strPhotoUrls.EndsWith(",")) { strPhotoUrls = strPhotoUrls.Substring(0, strPhotoUrls.Length - 1); } int intAdminId = (int)ViewState["AdminId"]; DateTime dateTimeAdd = DateTime.Now; if (!"".Equals(strMsgError)) { HelperUtility.showAlert(strMsgError, "add.aspx?cid=" + intContractId); return; } // 验证完毕,提交数据 ModelSalesGoods model = new ModelSalesGoods(); model.id_contract = intContractId; model.name_product = strProductName; model.type = strType; model.name_factory = strFactoryName; model.unit = strUnit; model.amount = dcmAmount; model.price_unit = dcmPriceUnit; model.price_total = dcmPriceTotal; model.batch_number = strBatchNumber; model.validity_period = dateValidityPeriod; model.approval_number = strApprovalNumber; model.comment = strComment; model.photo_urls = strPhotoUrls; model.id_admin = intAdminId; model.time_add = dateTimeAdd; model.amount_stock = dcmAmount; int intId = BllSalesGoods.add(model); if (intId > 0) { strUrl = "list.aspx?cid=" + intContractId; HelperUtility.showAlert("添加成功!", strUrl); } else { strUrl = "add.aspx?cid=" + intContractId; HelperUtility.showAlert("添加失败,请联系管理员!", strUrl); } }
public static int add(ModelSalesGoods model) { return(DalSalesGoods.add(model)); }
public static int update(ModelSalesGoods model) { return(DalSalesGoods.update(model)); }