//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { if (this._self != "1") { ChkAdminLevel("sys_invoice", DTEnums.ActionEnum.Delete.ToString()); //检查权限 } BLL.invoices bll = new BLL.invoices(); manager = GetAdminInfo(); string result = ""; int success = 0, error = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { result = bll.Delete(Convert.ToInt32(id), manager); if (result == "") { success++; } else { error++; sb.Append(result + "<br/>"); } } } JscriptMsg("共选择" + (success + error) + "条记录,成功" + success + "条,失败" + error + "条<br/>" + sb.ToString(), Utils.CombUrlTxt("invoice_list.aspx", "page={0}&txtCusName={1}&hCusId={2}&ddlcheck1={3}&ddlcheck2={4}&ddlcheck3={5}&ddlisConfirm={6}&txtOid={7}&self={8}&ddlsign={9}&txtMoney={10}&txtsDate={11}&txteDate={12}&ddlfarea={13}&ddldarea={14}&ddlinvType={15}&txtName={16}", "__id__", _cusName, _cid, _check1, _check2, _check3, _isconfirm, _oid, _self, _sign, _money, _sdate, _edate, _farea, _darea, _invType, _name)); }
private void RptBind(string _strWhere, string _orderby) { if (!this.isSearch) { this.page = DTRequest.GetQueryInt("page", 1); } else { this.page = 1; } BLL.invoices bll = new BLL.invoices(); DataTable dt = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, manager, out this.totalCount, out _tmoney).Tables[0]; this.rptList.DataSource = dt; this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = backUrl(); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); pCount.Text = dt.Rows.Count.ToString(); decimal _pmoney = 0; if (dt != null) { foreach (DataRow dr in dt.Rows) { _pmoney += Utils.ObjToDecimal(dr["inv_money"], 0); } } pMoney.Text = _pmoney.ToString(); tCount.Text = totalCount.ToString(); tMoney.Text = _tmoney.ToString(); txtCusName.Text = _cusName; hCusId.Value = _cid; ddlchecktype.SelectedValue = this._check; ddlcheck1.SelectedValue = _check1; ddlcheck2.SelectedValue = _check2; ddlcheck3.SelectedValue = _check3; ddlisConfirm.SelectedValue = _isconfirm; txtOid.Text = _oid; ddlsign.SelectedValue = _sign; txtMoney.Text = _money; txtsDate.Text = _sdate; txteDate.Text = _edate; ddlfarea.SelectedValue = _farea; ddldarea.SelectedValue = _darea; ddlinvType.SelectedValue = _invType; txtName.Text = _name; txtUnit.Text = _unit; txtpurchaserName.Text = _purchaserName; }
private string DoAdd() { Model.invoices model = new Model.invoices(); BLL.invoices bll = new BLL.invoices(); manager = GetAdminInfo(); model.inv_oid = oID; model.inv_cid = Utils.StrToInt(Request["hCusId"], 0); if (string.IsNullOrEmpty(ddlinvType.SelectedValue)) { return("请选择专普票类型"); } model.inv_type = ddlinvType.SelectedValue; model.inv_purchaserName = txtpurchaserName.Text.Trim(); model.inv_purchaserNum = txtpurchaserNum.Text.Trim(); model.inv_purchaserAddress = txtpurchaserAddress.Text.Trim(); model.inv_purchaserPhone = txtpurchaserPhone.Text.Trim(); model.inv_purchaserBank = txtpurchaserBank.Text.Trim(); model.inv_purchaserBankNum = txtpurchaserBankNum.Text.Trim(); model.inv_serviceType = ddlserviceType.SelectedItem.Text; if (ddlserviceType.SelectedValue == "4") { model.inv_serviceName = txtserviceName.Text; } else { model.inv_serviceName = ddlserviceName.SelectedItem.Text; } model.inv_money = Utils.StrToDecimal(txtmoney.Text.Trim(), 0); model.inv_sentWay = ddlsentWay.SelectedItem.Text; model.inv_farea = manager.area; model.inv_darea = ddldarea.SelectedValue; model.inv_unit = Utils.StrToInt(ddlunit.SelectedValue, 0); model.inv_receiveName = txtreceiveName.Text.Trim(); model.inv_receivePhone = txtreceivePhone.Text.Trim(); model.inv_receiveAddress = txtreceiveAddress.Text.Trim(); model.inv_remark = txtremark.Text.Trim(); model.inv_personName = manager.real_name; model.inv_personNum = manager.user_name; model.inv_addDate = DateTime.Now; model.inv_flag1 = 0; model.inv_flag2 = 0; model.inv_flag3 = 0; model.inv_isConfirm = false; return(bll.Add(model, manager)); }
private void ShowInfo(string _oid) { rptEmployee0.Visible = false; liemployee0.Visible = false; BLL.Order bll = new BLL.Order(); DataSet ds = bll.GetList(0, "o_id='" + _oid + "'", "o_addDate desc"); if (ds == null || ds.Tables[0].Rows.Count == 0) { JscriptMsg("订单不存在!", ""); return; } DataRow dr = ds.Tables[0].Rows[0]; labOwner.Text = new MettingSys.BLL.department().getAreaText(dr["op_area"].ToString()) + "," + dr["op_number"] + "," + dr["op_name"]; txtCusName.Text = dr["c_name"].ToString(); hCusId.Value = dr["c_id"].ToString(); List <Model.Contacts> contactlist = new BLL.Contacts().getList("co_cid=" + hCusId.Value + "", " co_flag desc,co_id asc"); if (contactlist != null) { ddlcontact.DataSource = contactlist; ddlcontact.DataTextField = "co_name"; ddlcontact.DataValueField = "co_id"; ddlcontact.DataBind(); } ddlcontact.SelectedValue = dr["o_coid"].ToString(); txtPhone.Text = dr["co_number"].ToString(); ddlcontractPrice.SelectedValue = dr["o_contractPrice"].ToString(); txtsDate.Text = ConvertHelper.toDate(dr["o_sdate"]).Value.ToString("yyyy-MM-dd"); txteDate.Text = ConvertHelper.toDate(dr["o_edate"]).Value.ToString("yyyy-MM-dd"); txtAddress.Text = dr["o_address"].ToString(); txtContent.Text = dr["o_content"].ToString(); txtContract.Text = dr["o_contractContent"].ToString(); txtRemark.Text = dr["o_remarks"].ToString(); ddlfStatus.SelectedValue = dr["o_status"].ToString(); //ddldstatus.SelectedValue = dr["o_dstatus"].ToString(); ddlpushStatus.SelectedValue = dr["o_isPush"].ToString(); labFlag.Text = Common.BusinessDict.checkStatus()[Utils.ObjToByte(dr["o_flag"])]; ddlflag.SelectedValue = dr["o_flag"].ToString(); labLockStatus.Text = Common.BusinessDict.lockStatus()[Utils.ObjToByte(dr["o_lockStatus"])]; labfinanceCost.Text = dr["o_financeCust"].ToString(); txtCost.Text = dr["o_financeCust"].ToString(); finCost = Utils.StrToDecimal(dr["o_financeCust"].ToString(), 0); ddllockstatus.SelectedValue = dr["o_lockStatus"].ToString(); labFinRemarks.Text = dr["o_finRemarks"].ToString(); txtFinRemark.Text = dr["o_finRemarks"].ToString(); labStatusTime.Text = Utils.ObjectToStr(dr["o_statusTime"]) == "" ? "" : Utils.StrToDateTime(Utils.ObjectToStr(dr["o_statusTime"])).ToString("yyyy-MM-dd HH:mm:ss"); #region 归属地 string placeStr = dr["o_place"].ToString(); if (!string.IsNullOrEmpty(placeStr)) { Dictionary <string, string> areaDic = new BLL.department().getAreaDict(); Dictionary <string, string> orderAreaDic = new Dictionary <string, string>(); string[] list = placeStr.Split(','); foreach (string item in list) { if (areaDic.ContainsKey(item)) { orderAreaDic.Add(item, areaDic[item]); } } rptAreaList.DataSource = orderAreaDic; rptAreaList.DataBind(); } #endregion #region 人员 DataTable pdt = bll.GetPersonList(0, "op_oid='" + _oid + "'", "op_id asc").Tables[0]; if (pdt != null && pdt.Rows.Count > 0) { rptEmployee1.DataSource = pdt.Select("op_type=2"); rptEmployee1.DataBind(); rptEmployee2.DataSource = pdt.Select("op_type=3"); rptEmployee2.DataBind(); rptEmployee3.DataSource = pdt.Select("op_type=4"); rptEmployee3.DataBind(); rptEmployee4.DataSource = pdt.Select("op_type=5"); rptEmployee4.DataBind(); liplace.Visible = false; liemployee1.Visible = false; liemployee2.Visible = false; liemployee3.Visible = false; liemployee4.Visible = false; uploadDiv.Visible = false; uploadDiv2.Visible = false; btnSave.Visible = false; btnDstatus.Visible = false; btnFlag.Visible = false; btnLockstatus.Visible = false; btnUpdateCost.Visible = false; btnUnBusinessPay.Visible = false; btnReceiptPay.Visible = false; btnFinRemark.Visible = false; //btnPay.Visible = false; btnInvoince.Visible = false; //btnExcelIn.Visible = false; btnSharing.Visible = false; trFile.Visible = false; #region 根据当前登录账户显示不同按钮 DataRow[] drs1 = pdt.Select("op_type=1 and op_number='" + manager.user_name + "'"); //业务员 DataRow[] drs2 = pdt.Select("op_type=2 and op_number='" + manager.user_name + "'"); //业务报账人员 DataRow[] drs3 = pdt.Select("op_type=3 and op_number='" + manager.user_name + "'"); //业务策划人员 DataRow[] drs4 = pdt.Select("op_type=4 and op_number='" + manager.user_name + "'"); //业务执行人员 DataRow[] drs6 = pdt.Select("op_type=5 and op_number='" + manager.user_name + "'"); //业务设计人员 bool showDetail = false; if (drs4.Length > 0) { isExecutiver = true; showDetail = true; uploadDiv.Visible = true; btnUnBusinessPay.Visible = true; btnReceiptPay.Visible = true; //btnPay.Visible = true; btnInvoince.Visible = true; //btnExcelIn.Visible = true; } if (drs3.Length > 0 || drs6.Length > 0) { showDetail = true; uploadDiv.Visible = true; uploadDiv2.Visible = true; btnDstatus.Visible = true; trFile.Visible = true; if (drs3.Length > 0) { ddldstatus.SelectedValue = drs3[0]["op_dstatus"].ToString(); } else if (drs6.Length > 0) { ddldstatus.SelectedValue = drs6[0]["op_dstatus"].ToString(); } } if (drs2.Length > 0) { isExecutiver = false; showDetail = true; liplace.Visible = true; liemployee2.Visible = true; liemployee3.Visible = true; liemployee4.Visible = true; uploadDiv.Visible = true; uploadDiv2.Visible = true; btnUnBusinessPay.Visible = true; btnReceiptPay.Visible = true; btnSave.Visible = true; //btnPay.Visible = true; btnInvoince.Visible = true; //btnExcelIn.Visible = true; trFile.Visible = true; } if (drs1.Length > 0) { isExecutiver = false; showDetail = true; liplace.Visible = true; liemployee1.Visible = true; liemployee2.Visible = true; liemployee3.Visible = true; liemployee4.Visible = true; uploadDiv.Visible = true; uploadDiv2.Visible = true; btnSave.Visible = true; btnUnBusinessPay.Visible = true; btnReceiptPay.Visible = true; //btnPay.Visible = true; btnInvoince.Visible = true; //btnExcelIn.Visible = true; trFile.Visible = true; } DataRow[] drs5 = pdt.Select("op_type=1"); //判断是否含有查看本区域数据的权限 if (new BLL.permission().checkHasPermission(manager, "0602") && (drs5[0]["op_area"].ToString() == manager.area || Utils.ObjectToStr(dr["o_place"]).IndexOf(manager.area) > -1)) { showDetail = true; trFile.Visible = true; } string groupArea = new BLL.department().getGroupArea();//总部 //判断是否是本区域,且含有财务基本权限 if ((drs5[0]["op_area"].ToString() == manager.area || groupArea == manager.area) && new BLL.permission().checkHasPermission(manager, "0401")) { showDetail = true; trFile.Visible = true; btnUnBusinessPay.Visible = true; btnReceiptPay.Visible = true; uploadDiv2.Visible = true; //btnPay.Visible = true; btnInvoince.Visible = true; //btnExcelIn.Visible = true; } //判断是否含有查看本区域审批权限 if (drs5[0]["op_area"].ToString() == manager.area && new BLL.permission().checkHasPermission(manager, "0603")) { trFile.Visible = true; showDetail = true; btnFlag.Visible = true; } // if (groupArea == manager.area) { if (new BLL.permission().checkHasPermission(manager, "0401")) { showDetail = true; trFile.Visible = true; } if (new BLL.permission().checkHasPermission(manager, "0405")) { showDetail = true; btnLockstatus.Visible = true; btnUpdateCost.Visible = true; trFile.Visible = true; } } if (new BLL.permission().checkHasPermission(manager, "0401")) { btnFinRemark.Visible = true; if (!Utils.StrToBool(dr["o_lockStatus"].ToString(), false)) { btnSharing.Visible = true; } } //以上都没有权限的,不能查看订单详细 if (!showDetail) { string msgbox = "parent.jsdialog(\"错误提示\", \"您没有管理该页面的权限,请勿非法进入!\", \"back\")"; Response.Write("<script type=\"text/javascript\">" + msgbox + "</script>"); Response.End(); } #endregion } #endregion if (dr["o_lockStatus"].ToString() == "1") { liplace.Visible = false; liemployee1.Visible = false; liemployee2.Visible = false; liemployee3.Visible = false; liemployee4.Visible = false; uploadDiv.Visible = false; uploadDiv2.Visible = false; btnSave.Visible = false; btnDstatus.Visible = false; btnFlag.Visible = false; btnUpdateCost.Visible = false; btnUnBusinessPay.Visible = false; btnReceiptPay.Visible = false; //btnPay.Visible = false; btnInvoince.Visible = true; //btnExcelIn.Visible = false; } #region 活动文件 DataTable fdt = bll.GetFileList(0, "f_oid='" + _oid + "'", "f_addDate asc,f_id asc").Tables[0]; if (fdt != null && fdt.Rows.Count > 0) { rptAlbumList.DataSource = fdt.Select("f_type=1"); rptAlbumList.DataBind(); rptAlbumList2.DataSource = fdt.Select("f_type=2"); rptAlbumList2.DataBind(); } #endregion string sqlwhere = ""; #region 执行备用金借款明细 if (isExecutiver) { sqlwhere = " and uba_PersonNum='" + manager.user_name + "'"; } DataSet unBusinessData = new BLL.unBusinessApply().GetList(0, "uba_oid='" + _oid + "' " + sqlwhere + "", "uba_addDate desc,uba_id desc"); if (unBusinessData != null && unBusinessData.Tables[0].Rows.Count > 0) { rptunBusinessList.DataSource = unBusinessData; rptunBusinessList.DataBind(); } #endregion #region 应收付 DataTable natureData = new BLL.finance().getNature(_oid, isExecutiver ? manager.user_name : ""); if (natureData != null && natureData.Rows.Count > 0) { rptNature.DataSource = natureData; rptNature.DataBind(); } #endregion #region 发票 if (isExecutiver) { sqlwhere = " and inv_personNum='" + manager.user_name + "'"; } DataTable invoiceData = new BLL.invoices().GetList(0, "inv_oid='" + _oid + "' " + sqlwhere + "", "inv_addDate desc,inv_id desc").Tables[0]; if (invoiceData != null && invoiceData.Rows.Count > 0) { foreach (DataRow inv in invoiceData.Rows) { if (inv["inv_flag1"].ToString() != "1" && inv["inv_flag2"].ToString() != "1" && inv["inv_flag3"].ToString() != "1") { requestMoney += Utils.StrToDecimal(inv["inv_money"].ToString(), 0); } if (Utils.StrToBool(inv["inv_isConfirm"].ToString(), false)) { confirmMoney += Utils.StrToDecimal(inv["inv_money"].ToString(), 0); } } rptInvoiceList.DataSource = invoiceData; rptInvoiceList.DataBind(); } #endregion #region 已收付款 if (isExecutiver) { sqlwhere = " and rpd_personNum='" + manager.user_name + "'"; } DataTable rpData = new BLL.ReceiptPayDetail().GetList(0, "rpd_oid='" + _oid + "'", "rpd_type desc,rpd_adddate desc,rpd_id desc").Tables[0]; if (rpData != null && rpData.Rows.Count > 0) { rptList.DataSource = rpData; rptList.DataBind(); } #endregion #region 结算汇总 if (!isExecutiver)//执行人员不可查看 { DataTable collectData = bll.getOrderCollect(_oid); if (collectData != null && collectData.Rows.Count > 0) { foreach (DataRow inv in collectData.Rows) { finProfit += Utils.StrToDecimal(inv["profit"].ToString(), 0); if (inv["fin_type"].ToString() == "True") { fin1 += Utils.StrToDecimal(inv["finMoney"].ToString(), 0); } else { fin0 += Utils.StrToDecimal(inv["finMoney"].ToString(), 0); } } rptCollect.DataSource = collectData; rptCollect.DataBind(); } } #endregion }
private string DoEdit(int _id) { BLL.invoices bll = new BLL.invoices(); Model.invoices model = bll.GetModel(_id); manager = GetAdminInfo(); string _content = ""; if (model.inv_purchaserName != txtpurchaserName.Text.Trim()) { _content += "购买方名称:" + model.inv_purchaserName + "→<font color='red'>" + txtpurchaserName.Text.Trim() + "</font><br/>"; } model.inv_purchaserName = txtpurchaserName.Text.Trim(); if (model.inv_purchaserNum != txtpurchaserNum.Text.Trim()) { _content += "购买方纳税人识别号:" + model.inv_purchaserNum + "→<font color='red'>" + txtpurchaserNum.Text.Trim() + "</font><br/>"; } model.inv_purchaserNum = txtpurchaserNum.Text.Trim(); if (model.inv_purchaserAddress != txtpurchaserAddress.Text.Trim()) { _content += "购买方纳税人识别号:" + model.inv_purchaserAddress + "→<font color='red'>" + txtpurchaserAddress.Text.Trim() + "</font><br/>"; } model.inv_purchaserAddress = txtpurchaserAddress.Text.Trim(); if (model.inv_purchaserPhone != txtpurchaserPhone.Text.Trim()) { _content += "购买方地址:" + model.inv_purchaserPhone + "→<font color='red'>" + txtpurchaserPhone.Text.Trim() + "</font><br/>"; } model.inv_purchaserPhone = txtpurchaserPhone.Text.Trim(); if (model.inv_purchaserBank != txtpurchaserBank.Text.Trim()) { _content += "购买方电话:" + model.inv_purchaserBank + "→<font color='red'>" + txtpurchaserBank.Text.Trim() + "</font><br/>"; } model.inv_purchaserBank = txtpurchaserBank.Text.Trim(); if (model.inv_purchaserBankNum != txtpurchaserBankNum.Text.Trim()) { _content += "购买方开户行:" + model.inv_purchaserBankNum + "→<font color='red'>" + txtpurchaserBankNum.Text.Trim() + "</font><br/>"; } model.inv_purchaserBankNum = txtpurchaserBankNum.Text.Trim(); if (model.inv_serviceType != ddlserviceType.SelectedItem.Text) { _content += "应税劳务:" + model.inv_serviceType + "→<font color='red'>" + ddlserviceType.SelectedItem.Text + "</font><br/>"; } model.inv_serviceType = ddlserviceType.SelectedItem.Text; if (ddlserviceType.SelectedValue == "4") { if (model.inv_serviceName != txtserviceName.Text) { _content += "服务名称:" + model.inv_serviceName + "→<font color='red'>" + txtserviceName.Text + "</font><br/>"; } model.inv_serviceName = txtserviceName.Text; } else { if (model.inv_serviceName != ddlserviceName.SelectedItem.Text) { _content += "服务名称:" + model.inv_serviceName + "→<font color='red'>" + ddlserviceName.SelectedItem.Text + "</font><br/>"; } model.inv_serviceName = ddlserviceName.SelectedItem.Text; } if (string.IsNullOrEmpty(ddlinvType.SelectedValue)) { return("请选择发票类型"); } if (model.inv_type != ddlinvType.SelectedValue) { _content += "发票类型:" + model.inv_type + "→<font color='red'>" + ddlinvType.SelectedValue + "</font><br/>"; } model.inv_type = ddlinvType.SelectedValue; decimal _money = 0; if (!decimal.TryParse(txtmoney.Text.Trim(), out _money)) { return("请正确填写开票金额"); } if (model.inv_money != _money) { _content += "开票金额:" + model.inv_money + "→<font color='red'>" + _money + "</font><br/>"; } model.inv_money = _money; if (model.inv_sentWay != ddlsentWay.SelectedItem.Text) { _content += "送票方式:" + model.inv_sentWay + "→<font color='red'>" + ddlsentWay.SelectedItem.Text + "</font><br/>"; } model.inv_sentWay = ddlsentWay.SelectedItem.Text; if (model.inv_darea != ddldarea.SelectedValue) { _content += "开票区域:" + model.inv_darea + "→<font color='red'>" + ddldarea.SelectedValue + "</font><br/>"; } model.inv_darea = ddldarea.SelectedValue; if (model.inv_unit != Utils.StrToInt(ddlunit.SelectedValue, 0)) { _content += "开票单位:" + model.inv_unit + "→<font color='red'>" + ddlunit.SelectedValue + "</font><br/>"; } model.inv_unit = Utils.StrToInt(ddlunit.SelectedValue, 0); if (model.inv_receiveName != txtreceiveName.Text.Trim()) { _content += "收票人名称:" + model.inv_receiveName + "→<font color='red'>" + txtreceiveName.Text.Trim() + "</font><br/>"; } model.inv_receiveName = txtreceiveName.Text.Trim(); if (model.inv_receivePhone != txtreceivePhone.Text.Trim()) { _content += "收票人电话:" + model.inv_receivePhone + "→<font color='red'>" + txtreceivePhone.Text.Trim() + "</font><br/>"; } model.inv_receivePhone = txtreceivePhone.Text.Trim(); if (model.inv_receiveAddress != txtreceiveAddress.Text.Trim()) { _content += "收票人地址:" + model.inv_receiveAddress + "→<font color='red'>" + txtreceiveAddress.Text.Trim() + "</font><br/>"; } model.inv_receiveAddress = txtreceiveAddress.Text.Trim(); if (model.inv_remark != txtremark.Text.Trim()) { _content += "备注:" + model.inv_remark + "→<font color='red'>" + txtremark.Text.Trim() + "</font><br/>"; } model.inv_remark = txtremark.Text.Trim(); return(bll.Update(model, _content, manager)); }
private void ShowInfo(int _id) { btnAudit.Visible = false; BLL.invoices bll = new BLL.invoices(); DataSet ds = bll.GetList(0, "inv_id=" + _id + "", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; oID = dr["inv_oid"].ToString(); txtCusName.Text = dr["c_name"].ToString(); hCusId.Value = dr["inv_cid"].ToString(); labCusName.Text = dr["c_name"].ToString(); txtpurchaserName.Text = dr["inv_purchaserName"].ToString(); txtpurchaserNum.Text = dr["inv_purchaserNum"].ToString(); txtpurchaserAddress.Text = dr["inv_purchaserAddress"].ToString(); txtpurchaserPhone.Text = dr["inv_purchaserPhone"].ToString(); txtpurchaserBank.Text = dr["inv_purchaserBank"].ToString(); txtpurchaserBankNum.Text = dr["inv_purchaserBankNum"].ToString(); txtmoney.Text = dr["inv_money"].ToString(); labOverMoney.Text = dr["inv_overmoney"].ToString(); txtreceiveName.Text = dr["inv_receiveName"].ToString(); txtreceivePhone.Text = dr["inv_receivePhone"].ToString(); txtreceiveAddress.Text = dr["inv_receiveAddress"].ToString(); txtremark.Text = dr["inv_remark"].ToString(); Dictionary <byte?, string> stype = Common.BusinessDict.taxableType(); byte?_type = 0; foreach (var item in stype.Keys) { if (stype[item].ToString() == dr["inv_serviceType"].ToString()) { ddlserviceType.SelectedValue = item.ToString(); _type = Utils.ObjToByte(item); break; } } if (_type == 4) { ddlserviceName.Visible = false; txtserviceName.Visible = true; txtserviceName.Text = dr["inv_serviceName"].ToString(); } else { ddlserviceName.Visible = true; txtserviceName.Visible = false; Dictionary <byte?, string> sname = Common.BusinessDict.serviceName(_type); ddlserviceName.DataSource = sname; ddlserviceName.DataTextField = "value"; ddlserviceName.DataValueField = "key"; ddlserviceName.DataBind(); ddlserviceName.Items.Insert(0, new ListItem("请选择", "")); foreach (var item in sname.Keys) { if (sname[item].ToString() == dr["inv_serviceName"].ToString()) { ddlserviceName.SelectedValue = item.ToString(); break; } } } Dictionary <byte?, string> smethod = Common.BusinessDict.sentMethod(); foreach (var item in smethod.Keys) { if (smethod[item].ToString() == dr["inv_sentWay"].ToString()) { ddlsentWay.SelectedValue = item.ToString(); break; } } ddldarea.SelectedValue = dr["inv_darea"].ToString(); BindUnit(ddldarea.SelectedValue); ddlunit.SelectedValue = dr["inv_unit"].ToString(); ddlinvType.SelectedValue = dr["inv_type"].ToString(); if (((manager.area == dr["inv_farea"].ToString() || manager.area == dr["inv_darea"].ToString()) && new MettingSys.BLL.permission().checkHasPermission(manager, "0603")) || new MettingSys.BLL.permission().checkHasPermission(manager, "0402")) { btnAudit.Visible = true; ddlflag.DataSource = Common.BusinessDict.checkStatus(); ddlflag.DataTextField = "value"; ddlflag.DataValueField = "key"; ddlflag.DataBind(); ddlflag.Items.Insert(0, new ListItem("请选择", "")); if (new MettingSys.BLL.permission().checkHasPermission(manager, "0603")) { if (dr["inv_farea"].ToString() == dr["inv_darea"].ToString()) { if (dr["inv_flag1"].ToString() != "2") { ddlchecktype.SelectedValue = "1"; ddlflag.SelectedValue = dr["inv_flag1"].ToString(); txtCheckRemark.Text = dr["inv_checkRemark1"].ToString(); } if (dr["inv_flag2"].ToString() == "2") { ddlchecktype.SelectedValue = "2"; ddlflag.SelectedValue = dr["inv_flag2"].ToString(); txtCheckRemark.Text = dr["inv_checkRemark2"].ToString(); } } else { if (manager.area == dr["inv_farea"].ToString()) { ddlchecktype.SelectedValue = "1"; ddlflag.SelectedValue = dr["inv_flag1"].ToString(); txtCheckRemark.Text = dr["inv_checkRemark1"].ToString(); } if (manager.area == dr["inv_darea"].ToString()) { ddlchecktype.SelectedValue = "2"; ddlflag.SelectedValue = dr["inv_flag2"].ToString(); txtCheckRemark.Text = dr["inv_checkRemark2"].ToString(); } } } if (new MettingSys.BLL.permission().checkHasPermission(manager, "0402")) { ddlchecktype.SelectedValue = "3"; ddlflag.SelectedValue = dr["inv_flag3"].ToString(); txtCheckRemark.Text = dr["inv_checkRemark3"].ToString(); } } } txtCusName.Visible = false; }
protected void btnExcel_Click(object sender, EventArgs e) { _cusName = DTRequest.GetFormString("txtCusName"); _cid = DTRequest.GetFormString("hCusId"); _check1 = DTRequest.GetFormString("ddlcheck1"); _check2 = DTRequest.GetFormString("ddlcheck2"); _check3 = DTRequest.GetFormString("ddlcheck3"); _isconfirm = DTRequest.GetFormString("ddlisConfirm"); _oid = DTRequest.GetFormString("txtOid"); _sign = DTRequest.GetFormString("ddlsign"); _money = DTRequest.GetFormString("txtMoney"); _sdate = DTRequest.GetFormString("txtsDate"); _edate = DTRequest.GetFormString("txteDate"); _farea = DTRequest.GetFormString("ddlfarea"); _darea = DTRequest.GetFormString("ddldarea"); _invType = DTRequest.GetFormString("ddlinvType"); _name = DTRequest.GetFormString("txtName"); _unit = DTRequest.GetFormString("txtUnit"); _purchaserName = DTRequest.GetFormString("txtpurchaserName"); _self = DTRequest.GetFormString("self");//self=1表示个人页面 BLL.invoices bll = new BLL.invoices(); DataTable dt = bll.GetList(this.pageSize, this.page, "inv_id>0" + CombSqlTxt(), "inv_addDate desc,inv_id desc", manager, out this.totalCount, out _tmoney, false).Tables[0]; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=发票列表.xlsx"); //HttpUtility.UrlEncode(fileName)); HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HSSFWorkbook hssfworkbook = new HSSFWorkbook(); ISheet sheet = hssfworkbook.CreateSheet("明细"); IFont font = hssfworkbook.CreateFont(); font.Boldweight = short.MaxValue; font.FontHeightInPoints = 11; #region 表格样式 //设置单元格的样式:水平垂直对齐居中 ICellStyle cellStyle = hssfworkbook.CreateCellStyle(); cellStyle.Alignment = HorizontalAlignment.Center; cellStyle.VerticalAlignment = VerticalAlignment.Center; cellStyle.BorderBottom = BorderStyle.Thin; cellStyle.BorderLeft = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BottomBorderColor = HSSFColor.Black.Index; cellStyle.LeftBorderColor = HSSFColor.Black.Index; cellStyle.RightBorderColor = HSSFColor.Black.Index; cellStyle.TopBorderColor = HSSFColor.Black.Index; cellStyle.WrapText = true;//自动换行 //设置表头的样式:水平垂直对齐居中,加粗 ICellStyle titleCellStyle = hssfworkbook.CreateCellStyle(); titleCellStyle.Alignment = HorizontalAlignment.Center; titleCellStyle.VerticalAlignment = VerticalAlignment.Center; titleCellStyle.FillForegroundColor = HSSFColor.Grey25Percent.Index; //图案颜色 titleCellStyle.FillPattern = FillPattern.SparseDots; //图案样式 titleCellStyle.FillBackgroundColor = HSSFColor.Grey25Percent.Index; //背景颜色 //设置边框 titleCellStyle.BorderBottom = BorderStyle.Thin; titleCellStyle.BorderLeft = BorderStyle.Thin; titleCellStyle.BorderRight = BorderStyle.Thin; titleCellStyle.BorderTop = BorderStyle.Thin; titleCellStyle.BottomBorderColor = HSSFColor.Black.Index; titleCellStyle.LeftBorderColor = HSSFColor.Black.Index; titleCellStyle.RightBorderColor = HSSFColor.Black.Index; titleCellStyle.TopBorderColor = HSSFColor.Black.Index; //设置字体 titleCellStyle.SetFont(font); #endregion //表头 IRow headRow = sheet.CreateRow(0); headRow.HeightInPoints = 25; headRow.CreateCell(0).SetCellValue("客户"); headRow.CreateCell(1).SetCellValue("订单号"); headRow.CreateCell(2).SetCellValue("开票项目"); headRow.CreateCell(3).SetCellValue("开票金额"); headRow.CreateCell(4).SetCellValue("超开"); headRow.CreateCell(5).SetCellValue("送票方式"); headRow.CreateCell(6).SetCellValue("开票区域"); headRow.CreateCell(7).SetCellValue("申请人"); headRow.CreateCell(8).SetCellValue("申请区域审批"); headRow.CreateCell(9).SetCellValue("开票区域审批"); headRow.CreateCell(10).SetCellValue("财务审批"); headRow.CreateCell(11).SetCellValue("开票状态"); headRow.CreateCell(12).SetCellValue("开票日期"); headRow.CreateCell(13).SetCellValue("专普票"); headRow.CreateCell(14).SetCellValue("开票单位"); headRow.CreateCell(15).SetCellValue("购买方名称"); headRow.GetCell(0).CellStyle = titleCellStyle; headRow.GetCell(1).CellStyle = titleCellStyle; headRow.GetCell(2).CellStyle = titleCellStyle; headRow.GetCell(3).CellStyle = titleCellStyle; headRow.GetCell(4).CellStyle = titleCellStyle; headRow.GetCell(5).CellStyle = titleCellStyle; headRow.GetCell(6).CellStyle = titleCellStyle; headRow.GetCell(7).CellStyle = titleCellStyle; headRow.GetCell(8).CellStyle = titleCellStyle; headRow.GetCell(9).CellStyle = titleCellStyle; headRow.GetCell(10).CellStyle = titleCellStyle; headRow.GetCell(11).CellStyle = titleCellStyle; headRow.GetCell(12).CellStyle = titleCellStyle; headRow.GetCell(13).CellStyle = titleCellStyle; headRow.GetCell(14).CellStyle = titleCellStyle; headRow.GetCell(15).CellStyle = titleCellStyle; sheet.SetColumnWidth(0, 15 * 256); sheet.SetColumnWidth(1, 20 * 256); sheet.SetColumnWidth(2, 20 * 256); sheet.SetColumnWidth(3, 20 * 256); sheet.SetColumnWidth(4, 20 * 256); sheet.SetColumnWidth(5, 15 * 256); sheet.SetColumnWidth(6, 20 * 256); sheet.SetColumnWidth(7, 20 * 256); sheet.SetColumnWidth(8, 20 * 256); sheet.SetColumnWidth(9, 20 * 256); sheet.SetColumnWidth(10, 20 * 256); sheet.SetColumnWidth(11, 20 * 256); sheet.SetColumnWidth(12, 20 * 256); sheet.SetColumnWidth(13, 20 * 256); sheet.SetColumnWidth(14, 20 * 256); sheet.SetColumnWidth(15, 20 * 256); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { IRow row = sheet.CreateRow(i + 1); row.HeightInPoints = 22; row.CreateCell(0).SetCellValue(dt.Rows[i]["c_name"].ToString()); row.CreateCell(1).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_oid"])); row.CreateCell(2).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_serviceType"]) + "/" + Utils.ObjectToStr(dt.Rows[i]["inv_serviceName"])); row.CreateCell(3).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_money"])); row.CreateCell(4).SetCellValue("0"); row.CreateCell(5).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_sentWay"])); row.CreateCell(6).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["de_subname"])); row.CreateCell(7).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_personName"])); row.CreateCell(8).SetCellValue(dt.Rows[i]["inv_flag1"].ToString() == "0" ? "待审批" : dt.Rows[i]["inv_flag1"].ToString() == "1" ? "审批未通过" : "审批通过"); row.CreateCell(9).SetCellValue(dt.Rows[i]["inv_flag2"].ToString() == "0" ? "待审批" : dt.Rows[i]["inv_flag2"].ToString() == "1" ? "审批未通过" : "审批通过"); row.CreateCell(10).SetCellValue(dt.Rows[i]["inv_flag3"].ToString() == "0" ? "待审批" : dt.Rows[i]["inv_flag3"].ToString() == "1" ? "审批未通过" : "审批通过"); row.CreateCell(11).SetCellValue(Utils.StrToBool(Utils.ObjectToStr(dt.Rows[i]["inv_isConfirm"]), false) ? "已开票" : "未开票"); row.CreateCell(12).SetCellValue(ConvertHelper.toDate(dt.Rows[i]["inv_date"]) == null ? "" : ConvertHelper.toDate(dt.Rows[i]["inv_date"]).Value.ToString("yyyy-MM-dd")); row.CreateCell(13).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_type"])); row.CreateCell(14).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["invU_name"])); row.CreateCell(15).SetCellValue(Utils.ObjectToStr(dt.Rows[i]["inv_purchaserName"])); row.GetCell(0).CellStyle = cellStyle; row.GetCell(1).CellStyle = cellStyle; row.GetCell(2).CellStyle = cellStyle; row.GetCell(3).CellStyle = cellStyle; row.GetCell(4).CellStyle = cellStyle; row.GetCell(5).CellStyle = cellStyle; row.GetCell(6).CellStyle = cellStyle; row.GetCell(7).CellStyle = cellStyle; row.GetCell(8).CellStyle = cellStyle; row.GetCell(9).CellStyle = cellStyle; row.GetCell(10).CellStyle = cellStyle; row.GetCell(11).CellStyle = cellStyle; row.GetCell(12).CellStyle = cellStyle; row.GetCell(13).CellStyle = cellStyle; row.GetCell(14).CellStyle = cellStyle; row.GetCell(15).CellStyle = cellStyle; } } MemoryStream file = new MemoryStream(); hssfworkbook.Write(file); HttpContext.Current.Response.BinaryWrite(file.GetBuffer()); HttpContext.Current.Response.End(); }