protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesContract_update"); ViewState["AdminId"] = intAdminId; // 本页只能从list.aspx的编辑页转过来 // 因此要得到要修改的id值和页面的page值用于修改成功后返回 int intId = HelperUtility.getQueryInt("id"); ViewState["id"] = intId; int intPage = HelperUtility.getQueryInt("page"); ViewState["page"] = intPage; // 绑定销售公司名称的下拉列表数据 BllSalesCompany.bindRPT(rptName); // 根据入库单id查询得到入库单model ModelSalesContract model = BllSalesContract.getById(intId); int intCompanyId = model.id_company; if (intCompanyId > 0) { tbCompanyName.Text = (BllSalesCompany.getById(intCompanyId)).name; } else { tbCompanyName.Text = "未知公司"; } tbTimeSign.Value = model.time_sign.ToString("yyyy-MM-dd"); tbComment.Text = model.comment; } }
protected void btnEdit_Click(object sender, EventArgs e) { if (!HelperUtility.hasPurviewOP("SalesContract_update")) { HelperUtility.showAlert("没有操作权限", "/BackManager/home.aspx"); } int intAdminId = (int)ViewState["AdminId"]; int intId = (int)ViewState["id"]; int intPage = (int)ViewState["page"]; string strThisPageUrl = "edit.aspx?id=" + intId + "&page=" + intPage; string strMsgError = ""; // 验证输入 string strCompanyName = tbCompanyName.Text.Trim(); if ("".Equals(strCompanyName)) { strMsgError += "公司名不能为空!"; } string strTimeSign = tbTimeSign.Value.ToString(); if ("".Equals(strTimeSign)) { strMsgError += "入库单签发时间不能为空!"; } if (!HelperUtility.isDateType(strTimeSign)) { strMsgError += "入库单签发时间格式不正确!"; } string strComment = tbComment.Text.Trim(); if (strComment.Length > 500) { strMsgError += "备注信息不能超过500个字数!"; } if (!"".Equals(strMsgError)) { HelperUtility.showAlert(strMsgError, strThisPageUrl); return; } string strPhotoUrls = ""; // 验证完毕,提交数据 ModelSalesContract model = BllSalesContract.getById(intId); if (strCompanyName.Contains("未知公司")) { model.id_company = 0; } else { model.id_company = BllSalesCompany.getIdByName(strCompanyName, intAdminId); } model.id_admin = intAdminId; model.photo_urls = strPhotoUrls; model.comment = strComment; model.time_sign = Convert.ToDateTime(strTimeSign); // 更新数据库记录 BllSalesContract.update(model); // 跳转回列表页 Response.Redirect("/BackManager/sales_contract/list.aspx?page=" + intPage); }
// 导出入库单货品清单以便打印的Excel文件 protected void btnExportExcel_Click(object sender, EventArgs e) { int intContractId = Convert.ToInt32(ViewState["ContractId"]); string[] aryExcel = BllSalesContract.setExcel(intContractId); // 设置压缩文件的下载链接 hlDownloadExcel.NavigateUrl = HelperExcel.SetExcelZip(aryExcel); hlDownloadExcel.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_show"); ViewState["AdminId"] = intAdminId; // 本页只能从list.aspx的编辑页转过来 // 因此要得到要显示哪个入库单的cid值和页面的cpage值用于返回 int intContractId = HelperUtility.getQueryInt("cid"); if (intContractId == 0) { HelperUtility.showAlert("", "/BackManager/login.aspx"); } ViewState["ContractId"] = intContractId; ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage"); // 得到现在的页面值 int intCurrentPage = HelperUtility.getQueryInt("page"); if (intCurrentPage <= 0) { intCurrentPage = 1; } lblCurentPage.Text = intCurrentPage.ToString(); LoadDataPage(); // 设置其他控件值,以货币形式显示 2.5.ToString("C") // 得到入库单的信息 ModelSalesContract model = BllSalesContract.getById(intContractId); if (model.id_company > 0) { lblCompanyName.Text = "【" + BllSalesCompany.getById(model.id_company).name + "】"; } else { lblCompanyName.Text = "【预入库】"; } lblTimeCreate.Text = model.time_create.ToString("yyyy-MM-dd"); lblPriceTotal.Text = BllSalesGoods.getPriceTotal(intContractId).ToString("C"); hlBackContract.NavigateUrl = "../sales_contract/list.aspx?page=" + ViewState["ContractPage"]; hlAddNew.NavigateUrl = "add.aspx?cid=" + intContractId; // 绑定所有入库单的下拉列表 BllSalesContract.bindDDL(ddlSalesContract); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (!HelperUtility.hasPurviewOP("SalesContract_add")) { string strUrl = "/BackManager/home.aspx"; HelperUtility.showAlert("没有操作权限", strUrl); } string strMsgError = ""; string strCompanyName = tbCompanyName.Text.Trim(); if ("".Equals(strCompanyName)) { strMsgError += "公司名不能为空!"; } string strTimeSign = tbTimeSign.Value.ToString(); if ("".Equals(strTimeSign)) { strMsgError += "入库单签发时间不能为空!"; } if (!HelperUtility.isDateType(strTimeSign)) { strMsgError += "入库单签发时间格式不正确!"; } string strComment = tbComment.Text.Trim(); if (strComment.Length > 500) { strMsgError += "备注信息不能超过500个字数!"; } if (!"".Equals(strMsgError)) { HelperUtility.showAlert(strMsgError, "add.aspx"); return; } string strPhotoUrls = ""; // 验证完毕,提交数据 int intAdminId = (int)ViewState["AdminId"]; ModelSalesContract model = new ModelSalesContract(); if (strCompanyName.Contains("预入库")) { model.id_company = 0; } else { model.id_company = BllSalesCompany.getIdByName(strCompanyName, intAdminId); } model.id_admin = intAdminId; model.time_sign = Convert.ToDateTime(strTimeSign); model.photo_urls = strPhotoUrls; model.comment = strComment; int intId = BllSalesContract.add(model); if (intId > 0) { string strUrl = "list.aspx"; HelperUtility.showAlert("添加成功!", strUrl); } else { string strUrl = "add.aspx"; HelperUtility.showAlert("添加失败,请联系管理员!", strUrl); } }