//计算工资 private void CalculateSalary() { string year = dplYear.SelectedValue; string month = dplMoth.SelectedValue; CaculateBzAverage(); string js = hidJS.Value; string sql = "select DepartId,Score from View_TBDS_KaoheDepartMonth where DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and State='2' and DepartId='" + ddl_Depart.SelectedValue + "'"; DataTable dtPart = DBCallCommon.GetDTUsingSqlText(sql); if (dtPart.Rows.Count > 0) { for (int i = 0; i < dtPart.Rows.Count; i++) { string depId = dtPart.Rows[i]["DepartId"].ToString(); string score = dtPart.Rows[i]["Score"].ToString(); sql = "select sum(case when ST_GANGWEIXISHU='' or ST_GANGWEIXISHU is null then 1.00 else ST_GANGWEIXISHU end),sum(case when Kh_ScoreTotal is null then 0 else Kh_ScoreTotal end) from View_TBDS_JXGZ where Year='" + year + "' and Month='" + month + "' and DEP_CODE='" + depId + "'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { double zongXishu = CommonFun.ComTryDouble(dt.Rows[0][0].ToString()); double zongDeiFen = CommonFun.ComTryDouble(dt.Rows[0][1].ToString()); if (zongDeiFen == 0) { zongDeiFen = 1.0; } sql = "update a set Money=case when POSITION_NAME like '%部长%' or POSITION_NAME like '%主管%' then " + CommonFun.ComTryDouble(js) * CommonFun.ComTryDouble(score) / 100.0 + "*ST_GANGWEIXISHU else " + CommonFun.ComTryDouble(js) * zongXishu * CommonFun.ComTryDouble(score) / zongDeiFen / 100.0 + "*cast(b.Kh_ScoreTotal as float) end from TBDS_KaoHe_JXGZ as a left join View_TBDS_JXGZ as b on a.Id=b.Id inner join View_TBDS_KaoheDepartMonth as c on b.DEP_CODE=c.DepartId and b.Year=c.DepMonth_Year and b.Month=c.DepMonth_Month where c.state='2' and b.DEP_CODE='" + depId + "' "; DBCallCommon.ExeSqlText(sql); } } } }
public void CreateDataSource() { string sqlwhere = ""; string sqltext = ""; string nowtime = System.DateTime.Now.ToString("yyyy-MM-dd"); sqltext = "select * from VIEW_TBMP_Order where "; sqlwhere = "1=1 "; if (txt_docnum.Text != "") { sqlwhere = sqlwhere + "and TO_DOCNUM like '%" + txt_docnum.Text.Trim() + "%'"; } if (rad_mypart.Checked) { sqlwhere = sqlwhere + " and TO_ZDR='" + Session["UserID"].ToString() + "'"; } if (tb_supply.Text != "") { sqlwhere = sqlwhere + " and TO_SUPPLYNAME like '%" + tb_supply.Text.Trim() + "%'"; } if (ddl_bjstatus.SelectedIndex != 0) { sqlwhere = sqlwhere + " and PIC_BJSTATUS='" + ddl_bjstatus.SelectedValue.ToString() + "'"; } if (rbl_waixie.SelectedIndex != 0) { sqlwhere = sqlwhere + " and PIC_WXTYPE ='" + rbl_waixie.SelectedValue.ToString() + "'"; } if (ddlYear.SelectedIndex != 0 && ddlMonth.SelectedIndex != 0) { sqlwhere += " and substring(convert(varchar(50),TO_ZDTIME,23),1,7)='" + ddlYear.SelectedValue.ToString().Trim() + "-" + ddlMonth.SelectedValue.ToString().Trim() + "'"; } else if (ddlYear.SelectedIndex == 0 && ddlMonth.SelectedIndex != 0) { sqlwhere += " and convert(varchar(50),TO_ZDTIME,23) like '%-" + ddlMonth.SelectedValue.ToString().Trim() + "-%'"; } else if (ddlYear.SelectedIndex != 0 && ddlMonth.SelectedIndex == 0) { sqlwhere += " and convert(varchar(50),TO_ZDTIME,23) like '%" + ddlYear.SelectedValue.ToString().Trim() + "-%'"; } //计划跟踪号 if (txt_jhgzh.Text != "") { sqlwhere = sqlwhere + " and TO_PTC like '%" + txt_jhgzh.Text.Trim() + "%'"; } sqltext = sqltext + sqlwhere + " order by TO_DOCNUM"; System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sqltext); double tot_money = 0; for (int i = 0; i < dt.Rows.Count; i++) { //tot_money += Convert.ToDouble(dt.Rows[i]["TO_MONEY"].ToString()); tot_money += CommonFun.ComTryDouble(dt.Rows[i]["TO_MONEY"].ToString()); } lb_select_num.Text = Convert.ToString(dt.Rows.Count); lb_select_money.Text = string.Format("{0:c}", tot_money); ViewState["sqlwhere"] = sqlwhere; }
private void bindrpt() { pager_org.TableName = "EQU_GXHT"; pager_org.PrimaryKey = "HT_ID"; pager_org.ShowFields = "* "; pager_org.OrderField = "HT_HTBH"; pager_org.StrWhere = StrWhere(); pager_org.OrderType = 1;//升序排列 pager_org.PageSize = PageSize(); UCPaging1.PageSize = pager_org.PageSize; pager_org.PageIndex = UCPaging1.CurrentPage; DataTable dt = CommonFun.GetDataByPagerQueryParamWithPriKey(pager_org); CommonFun.Paging(dt, rptGXHT, UCPaging1, NoDataPane); int num = 0; double money = 0; foreach (RepeaterItem item in rptGXHT.Controls) { if (item.ItemType == ListItemType.Footer) { string sql = "select HT_ID,HT_HTBH,HT_HTZJ,HT_GF,HT_DH from EQU_GXHT where " + pager_org.StrWhere; DataTable dt1 = DBCallCommon.GetDTUsingSqlText(sql); foreach (DataRow dr in dt1.Rows) { string[] a = dr["HT_HTZJ"].ToString().Split(new char[] { '(', '元' }, StringSplitOptions.None); for (int i = 0, length = a.Length; i < length; i++) { money += CommonFun.ComTryDouble(a[i]); } } num = dt1.Rows.Count; ((Label)item.FindControl("lbNUM")).Text = num.ToString(); ((Label)item.FindControl("lbMONEY")).Text = money.ToString(); //if (num <= 1) //{ // btnBatchDelete.Visible = false; // quanxianKJ.Visible = false; //} break; } } for (int j = 0; j < rptGXHT.Items.Count; j++) { Label s = (Label)rptGXHT.Items[j].FindControl("lblXuHao"); s.Text = (j + 1 + (pager_org.PageIndex - 1) * UCPaging1.PageSize).ToString(); } if (NoDataPane.Visible) { UCPaging1.Visible = false; } else { UCPaging1.Visible = true; UCPaging1.InitPageInfo(); } BindrblSP(); }
private void CaculZongGZ(string context) { if (txtKhNianYue.Text == "") { Response.Write("<script>alert('请选择考核年月!')</script>"); return; } string year = txtKhNianYue.Text.Split('-')[0].ToString(); string month = txtKhNianYue.Text.Split('-')[1].PadLeft(2, '0'); string js = CaculateBzAverage(); string sql = ""; if (ddl_Depart.SelectedValue == "12") { sql = " select sum(GangWeiXiShu) from TBDS_KaoHe_JXDetail where Context='" + context + "' and PosName <> '部长' and PosName <> '副部长' and PosName not like '%总监%' and PosName not like '%总经理助理兼部长%'"; } else { sql = " select sum(GangWeiXiShu) from TBDS_KaoHe_JXDetail where Context='" + context + "' and PosName <> '部长' and PosName not like '%总监%' and PosName not like '%总经理助理兼部长%'"; } DataTable dtGWXS; try { dtGWXS = DBCallCommon.GetDTUsingSqlText(sql); } catch (Exception) { Response.Write("<script>alert('该部门岗位系数有误,请核实人员信息表!!!')</script>"); return; } sql = "select * from View_TBDS_KaoheDepartMonth where DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and state='2' and DepartId='" + ddl_Depart.SelectedValue + "'"; DataTable dtDepScore = DBCallCommon.GetDTUsingSqlText(sql); if (dtDepScore.Rows.Count > 0) { double zonggz = CommonFun.ComTryDouble(js) * CommonFun.ComTryDouble(dtGWXS.Rows[0][0].ToString()) * CommonFun.ComTryDouble(dtDepScore.Rows[0]["Score"].ToString()) / 100; sql = " select usermoney from OM_JXGZSYSP where yearmonth='" + year + "-" + month + "' and jxadddepartmentId='" + ddl_Depart.SelectedValue + "'"; DataTable dtYe = DBCallCommon.GetDTUsingSqlText(sql); double jyeDouble = 0; if (dtYe.Rows.Count > 0) { jyeDouble = CommonFun.ComTryDouble(dtYe.Rows[0][0].ToString()); } tb_yfpe.Text = zonggz.ToString("0.00"); tb_jye.Text = jyeDouble.ToString("0.00"); txtZonghe.Text = (zonggz + jyeDouble).ToString("0.00"); } else { Response.Write("<script>alert('未找到当月部门绩效考核数据!!!')</script>"); return; } }
//报价总计 private void GetlbBJZJ(System.Data.DataTable dt) { double detamounts = 0; for (int i = 0, length = dt.Rows.Count; i < length; i++) { detamounts += CommonFun.ComTryDouble(dt.Rows[i]["detamount"].ToString()); } lbBJZJ.Text = detamounts.ToString() + "元"; }
//保存修改 protected void btnbaocunxg_Click(object sender, EventArgs e) { List <string> sql = new List <string>(); double totalje = 0; double totalhsje = 0; string jhgzh = ""; double sl = 0; double je = 0; double zl = 0; double shuilv = 0; double se = 0; double hsje = 0; string fpbh = txtfpbh.Text.ToString(); string sqlstring = ""; //将数据写入发票勾稽关系表 for (int i = 0; i < rptProNumCost.Items.Count; i++) { jhgzh = ((Label)rptProNumCost.Items[i].FindControl("lbjhgzh")).Text.ToString(); //计划跟踪号 sl = CommonFun.ComTryDouble(((Label)rptProNumCost.Items[i].FindControl("lbsl")).Text.ToString()); //数量 zl = CommonFun.ComTryDouble(((Label)rptProNumCost.Items[i].FindControl("lbzl")).Text.ToString()); //重量 je = CommonFun.ComTryDouble(((TextBox)rptProNumCost.Items[i].FindControl("tbje")).Text.ToString()); //金额 shuilv = CommonFun.ComTryDouble(((TextBox)rptProNumCost.Items[i].FindControl("tbshuilv")).Text.ToString()); //税率 hsje = CommonFun.ComTryDouble(((TextBox)rptProNumCost.Items[i].FindControl("tbhsje")).Text.ToString()); //含税金额 se = CommonFun.ComTryDouble(((TextBox)rptProNumCost.Items[i].FindControl("tbse")).Text.ToString()); //税额 //if (sl.ToString() == "0") //{ // zl = 0; // je = 0; // hsje = 0; // se = 0; //} string sqltextgjgx = "update TBFM_YFFPDETAIL set YFGJ_NUM='" + sl + "',YFGJ_WGHT='" + zl + "',YFGJ_JE='" + je + "',YFGJ_SHUILV='" + shuilv + "',YFGJ_HSJE='" + hsje + "' where YFGJ_JHGZH='" + jhgzh + "'"; sql.Add(sqltextgjgx); totalje += je; totalhsje += hsje; } //更新发票总表金额 sqlstring = "update TBFM_YFFPTOTAL set YFGI_MONEY ='" + totalje + "',YFGI_HSMONEY ='" + totalhsje + "' where YFGI_CODE='" + fpbh + "'"; sql.Add(sqlstring); //更新发票总表信息 string fptotalsqltext = getfptotalsqltext(); sql.Add(fptotalsqltext); DBCallCommon.ExecuteTrans(sql); //重新绑定发票明细 this.BindInvrpt(yfgicode); this.BindInvHead(yfgicode); btnbaocunxg.Visible = true; btnshpass.Visible = true; btnshreject.Visible = false; btngjpass.Visible = false; btngjreject.Visible = false; }
//年月份改变查询 protected void OnSelectedIndexChanged_dplYearMoth(object sender, EventArgs e) { string sqltext = ""; if (dplYear.SelectedIndex != 0) { sqltext = "select * from FM_CWZHIBIAO where cw_yearmonth like '" + dplYear.SelectedValue.ToString().Trim() + "-%'"; System.Data.DataTable dt0 = DBCallCommon.GetDTUsingSqlText(sqltext); if (dt0.Rows.Count > 0) { yychengbenys.Text = dt0.Rows[0]["yychengbenys"].ToString().Trim(); xsfeiyongys.Text = dt0.Rows[0]["xsfeiyongys"].ToString().Trim(); glfeiyongys.Text = dt0.Rows[0]["glfeiyongys"].ToString().Trim(); cwfeiyongys.Text = dt0.Rows[0]["cwfeiyongys"].ToString().Trim(); cbfeiyonghjys.Text = dt0.Rows[0]["cbfeiyonghjys"].ToString().Trim(); yyshouruys.Text = dt0.Rows[0]["yyshouruys"].ToString().Trim(); lrzongeys.Text = dt0.Rows[0]["lrzongeys"].ToString().Trim(); } else { yychengbenys.Text = ""; xsfeiyongys.Text = ""; glfeiyongys.Text = ""; cwfeiyongys.Text = ""; cbfeiyonghjys.Text = ""; yyshouruys.Text = ""; lrzongeys.Text = ""; } if (dplYear.SelectedIndex != 0 && dplMoth.SelectedIndex != 0) { sqltext = "select * from TBFM_LRFP where RQBH='" + dplYear.SelectedValue.ToString().Trim() + "-" + dplMoth.SelectedValue.ToString().Trim() + "' and LRFP_TYPE='本年累计数'"; DataTable dt1 = DBCallCommon.GetDTUsingSqlText(sqltext); if (dt1.Rows.Count > 0) { yychengben.Text = Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_JYCB"].ToString().Trim())) / 10000), 2).ToString().Trim(); xsfeiyong.Text = Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_XSFY"].ToString().Trim())) / 10000), 2).ToString().Trim(); glfeiyong.Text = Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_GLFY"].ToString().Trim())) / 10000), 2).ToString().Trim(); cwfeiyong.Text = Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_CWFY"].ToString().Trim())) / 10000), 2).ToString().Trim(); cbfeiyonghj.Text = (Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_JYCB"].ToString().Trim())) / 10000), 2) + Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_XSFY"].ToString().Trim())) / 10000), 2) + Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_GLFY"].ToString().Trim())) / 10000), 2) + Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_CWFY"].ToString().Trim())) / 10000), 2)).ToString().Trim(); yyshouru.Text = Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR"].ToString().Trim())) / 10000), 2).ToString().Trim(); lrzonge.Text = (Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR"].ToString().Trim())) / 10000), 2) - Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_JYCB"].ToString().Trim())) / 10000), 2) - Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_XSFY"].ToString().Trim())) / 10000), 2) - Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_GLFY"].ToString().Trim())) / 10000), 2) - Math.Round(((CommonFun.ComTryDouble(dt1.Rows[0]["LRFP_YYSR_CWFY"].ToString().Trim())) / 10000), 2)).ToString().Trim(); } else { yychengben.Text = ""; xsfeiyong.Text = ""; glfeiyong.Text = ""; cwfeiyong.Text = ""; cbfeiyonghj.Text = ""; yyshouru.Text = ""; lrzonge.Text = ""; } } } }
private void writedata() { List <string> list_sql = new List <string>(); for (int i = 0; i < Repeater1.Items.Count; i++) { if (((TextBox)Repeater1.Items[i].FindControl("txt_shuliang")).Text != "") { mingchen = ((Label)Repeater1.Items[i].FindControl("lblbh")).Text; guige = ((Label)Repeater1.Items[i].FindControl("lblName")).Text;; danjia = ((Label)Repeater1.Items[i].FindControl("lbldanjia")).Text; danwei = ((Label)Repeater1.Items[i].FindControl("lbdanwei")).Text; shuliang = ((TextBox)Repeater1.Items[i].FindControl("txt_shuliang")).Text; double dj = CommonFun.ComTryDouble(danjia); double sl = CommonFun.ComTryDouble(shuliang); //比较库存数量与出库数量大小 string sql = "select * from OM_CARKUCUN where KC_MC='" + mingchen + "' and KC_GG='" + guige + "'and KC_DJ='" + dj + "'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); string kc_sl = dt.Rows[0]["KC_SL"].ToString(); double kcsl = CommonFun.ComTryDouble(kc_sl); if (kcsl >= sl) { double zongjia = dj * sl; string zj = zongjia.ToString(); //string sqltext = "insert into OM_CARKUCUN(KC_MC,KC_GG,KC_SL,KC_DJ,KC_ZJ,KC_SJ)"; //sqltext += "values('" + mingchen + "','" + guige + "','" + shuliang + "','" + danjia + "','" + zongjia + "','" + lblInDate.Text + "')"; //list_sql.Add(sqltext); string sqltext1 = string.Format("insert into OM_CARCK_SP (SP_MC,SP_GG,SP_SL,ZDR,ZDRID,ZDR_SJ,ZDR_JY,SPR1,SPR1_ID,SPR1_JL,SPR1_JY,SPR2,SPR2_ID,SPR2_JL,SPR2_JY,SP_DJ,SP_DANWEI,SPJB,SPZT,SP_ZJ) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')", mingchen, guige, shuliang, txtZDR.Text.Trim(), hidZDRID.Value, lbZDR_SJ.Text, txtZDR_JY.Text.Trim(), txtSPR1.Text.Trim(), hidSPR1_ID.Value, "", "", txtSPR2.Text.Trim(), hidSPR2_ID.Value, "", "", danjia, danwei, rblSPJB.SelectedValue, "0", zj); list_sql.Add(sqltext1); } else { Response.Write("<script>alert('库存数量不足,请查看正确数量!!!')</script>"); Response.Redirect("OM_CarKuCun.aspx"); } } else { Response.Write("<script>alert('请选择“名称、数量”再提交!!!')</script>"); } } DBCallCommon.ExecuteTrans(list_sql); string _emailto = DBCallCommon.GetEmailAddressByUserID(hidSPR1_ID.Value); string _body = "车品出库审批任务:" + "\r\n制单人:" + lbl_creater.Text.Trim() + "\r\n制单日期:" + lblInDate.Text.Trim(); string _subject = "您有新的【车品出库】需要审批,请及时处理"; DBCallCommon.SendEmail(_emailto, null, null, _subject, _body); }
protected void rptProNumCost_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string kcNum = ((Label)e.Item.FindControl("lblNum")).Text; string safeNum = ((Label)e.Item.FindControl("lblKC")).Text; if (CommonFun.ComTryDouble(kcNum) < CommonFun.ComTryDouble(safeNum)) { ((HtmlTableCell)e.Item.FindControl("td1")).BgColor = "Red"; } } }
private void bindrpt() { pager_org.TableName = "PC_CGHT"; pager_org.PrimaryKey = "HT_ID"; pager_org.ShowFields = "* "; pager_org.OrderField = "HT_ID"; pager_org.StrWhere = StrWhere(); pager_org.OrderType = 1;//升序排列 pager_org.PageSize = 15; UCPaging1.PageSize = pager_org.PageSize; pager_org.PageIndex = UCPaging1.CurrentPage; DataTable dt = CommonFun.GetDataByPagerQueryParamWithPriKey(pager_org); CommonFun.Paging(dt, rptCGHTGL, UCPaging1, palNoData); foreach (RepeaterItem item in rptCGHTGL.Controls) { if (item.ItemType == ListItemType.Footer) { double money = 0; int num = 0; string sql = "select * from PC_CGHT "; if (pager_org.StrWhere.Trim() != "") { sql += " where " + pager_org.StrWhere; } DataTable dt1 = DBCallCommon.GetDTUsingSqlText(sql); foreach (DataRow dr in dt1.Rows) { string[] a = dr["HT_HTZJ"].ToString().Split(new char[] { '(', ')' }, StringSplitOptions.None); for (int i = 0, length = a.Length; i < length; i++) { money += CommonFun.ComTryDouble(a[i]); } } num = dt1.Rows.Count; ((Label)item.FindControl("lbNUM")).Text = num.ToString(); ((Label)item.FindControl("lbMONEY")).Text = money.ToString(); break; } } if (palNoData.Visible) { UCPaging1.Visible = false; } else { UCPaging1.Visible = true; UCPaging1.InitPageInfo(); } BindrblSP(); }
private void updategeshui() { string gesdatasource = "select *,((QD_JCGZ+QD_GZGL+QD_GDGZ+QD_JXGZ+QD_JiangLi+QD_BingJiaGZ+QD_JiaBanGZ+QD_BFJB+QD_ZYBF+QD_BFZYB+QD_NianJiaGZ+QD_YKGW+QD_TZBF+QD_TZBK+QD_JTBT+QD_FSJW+QD_QTFY)-(QD_YLBX+QD_SYBX+QD_YiLiaoBX+QD_DEJZ+QD_BuBX+QD_GJJ+QD_BGJJ)-QD_KOUXIANG) as QD_KOUSJS from OM_GZQD left join OM_KQTJ on KQ_ST_ID=QD_STID and KQ_DATE=QD_YEARMONTH where QD_ID=" + CommonFun.ComTryInt(lbQD_ID.Text.ToString().Trim()) + ""; System.Data.DataTable dtdatasource = DBCallCommon.GetDTUsingSqlText(gesdatasource); List <string> listgeshui = new List <string>(); //个税 if (dtdatasource.Rows.Count > 0) { double ksjsmoney = CommonFun.ComTryDouble(dtdatasource.Rows[0]["QD_KOUSJS"].ToString().Trim()); double jsmoney = ksjsmoney - 3500; double geshui = 0; if (jsmoney > 0) { if (jsmoney < 1500) { geshui = jsmoney * 0.03; } else if (jsmoney >= 1500 && jsmoney < 4500) { geshui = jsmoney * 0.1 - 105; } else if (jsmoney >= 4500 && jsmoney < 9000) { geshui = jsmoney * 0.2 - 555; } else if (jsmoney >= 9000 && jsmoney < 35000) { geshui = jsmoney * 0.25 - 1005; } else { geshui = 0; } } string insertgeshui = "update OM_GZQD set QD_GeShui=" + Math.Round(geshui, 2) + " where QD_ID=" + CommonFun.ComTryInt(lbQD_ID.Text.ToString().Trim()) + ""; listgeshui.Add(insertgeshui); //插入修改记录 string sqlgetdata = "select * from OM_GZQD where QD_ID=" + CommonFun.ComTryInt(lbQD_ID.Text.ToString().Trim()) + ""; DataTable dtgetdata = DBCallCommon.GetDTUsingSqlText(sqlgetdata); if (dtgetdata.Rows.Count > 0) { listgeshui.Add("insert into OM_GZQDeditJL(QD_SHBH,QD_YEARMONTH,QD_STID,QD_HTZT,QD_QFBS,QD_JCGZ,QD_GZGL,QD_GDGZ,QD_JXGZ,QD_JiangLi,QD_BingJiaGZ,QD_JiaBanGZ,QD_BFJB,QD_ZYBF,QD_BFZYB,QD_NianJiaGZ,QD_YKGW,QD_TZBF,QD_TZBK,QD_QTFY,QD_JTBT,QD_FSJW,QD_CLBT,QD_YLBX,QD_SYBX,QD_YiLiaoBX,QD_DEJZ,QD_BuBX,QD_GJJ,QD_BGJJ,QD_ShuiDian,QD_KOUXIANG,QD_GeShui,QD_edittime,QD_editname,QD_NOTE) values('" + dtgetdata.Rows[0]["QD_SHBH"].ToString().Trim() + "','" + ddlYear.SelectedValue.ToString().Trim() + "-" + ddlMoth.SelectedValue.ToString().Trim() + "','" + dtgetdata.Rows[0]["QD_STID"].ToString().Trim() + "','" + dtgetdata.Rows[0]["QD_HTZT"].ToString().Trim() + "','" + txtQD_QuFen.Text.Trim() + "'," + CommonFun.ComTryDecimal(txtQD_JCGZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_GZGL.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_GDGZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_JXGZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_JiangLi.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_BingJiaGZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_JiaBanGZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_BFJB.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_ZYBF.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_BFZYB.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_NianJiaGZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_YKGW.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_TZBF.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_TZBK.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_QTFY.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_JTBT.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_FSJW.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_CLBT.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_YLBX.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_SYBX.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_YiLiaoBX.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_DEJZ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_BuBX.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_GJJ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_BGJJ.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_ShuiDian.Text.Trim()) + "," + CommonFun.ComTryDecimal(txtQD_KOUXIANG.Text.Trim()) + "," + Math.Round(geshui, 2) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "','" + Session["UserName"].ToString().Trim() + "','" + tbnote.Text.Trim() + "')"); } DBCallCommon.ExecuteTrans(listgeshui); } }
protected void rpt1_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } Label a = (Label)e.Item.FindControl("lbsjxs"); Label b = (Label)e.Item.FindControl("lbJBXS"); double sjxs = CommonFun.ComTryDouble(a.Text.ToString()); double jbxs = CommonFun.ComTryDouble(b.Text.ToString()); double c = 100 * sjxs / jbxs; ((Label)e.Item.FindControl("lbwcl")).Text = c.ToString("0.00") + "%"; }
private void updategeshui(string spbh) { List <string> listgeshui = new List <string>(); string sqltext01 = "select * from OM_GZTZSP as a left join OM_GZTZdetal as b on a.GZTZSP_SPBH=b.GZTZ_SPBH where GZTZSP_SPBH='" + spbh.Trim() + "'"; DataTable dt01 = DBCallCommon.GetDTUsingSqlText(sqltext01); if (dt01.Rows.Count > 0) { for (int j = 0; j < dt01.Rows.Count; j++) { string gesdatasource = "select *,((QD_JCGZ+QD_GZGL+QD_GDGZ+QD_JXGZ+QD_JiangLi+QD_BingJiaGZ+QD_JiaBanGZ+QD_BFJB+QD_ZYBF+QD_BFZYB+QD_NianJiaGZ+QD_YKGW+QD_TZBF+QD_TZBK+QD_JTBT+QD_FSJW+QD_QTFY)-(QD_YLBX+QD_SYBX+QD_YiLiaoBX+QD_DEJZ+QD_BuBX+QD_GJJ+QD_BGJJ)-QD_KOUXIANG) as QD_KOUSJS from OM_GZQD left join OM_KQTJ on KQ_ST_ID=QD_STID and KQ_DATE=QD_YEARMONTH where QD_YEARMONTH='" + dt01.Rows[j]["GZTZSP_YEARMONTH"].ToString().Trim() + "' and QD_STID='" + dt01.Rows[j]["GZTZ_STID"].ToString().Trim() + "' and QD_SHBH not in(select GZSH_BH from OM_GZHSB where OM_GZSCBZ='2')"; System.Data.DataTable dtdatasource = DBCallCommon.GetDTUsingSqlText(gesdatasource); //个税 if (dtdatasource.Rows.Count > 0) { double ksjsmoney = CommonFun.ComTryDouble(dtdatasource.Rows[0]["QD_KOUSJS"].ToString().Trim()); double jsmoney = ksjsmoney - 3500; double geshui = 0; if (jsmoney > 0) { if (jsmoney < 1500) { geshui = jsmoney * 0.03; } else if (jsmoney >= 1500 && jsmoney < 4500) { geshui = jsmoney * 0.1 - 105; } else if (jsmoney >= 4500 && jsmoney < 9000) { geshui = jsmoney * 0.2 - 555; } else if (jsmoney >= 9000 && jsmoney < 35000) { geshui = jsmoney * 0.25 - 1005; } else { geshui = 0; } } string insertgeshui = "update OM_GZQD set QD_GeShui=" + Math.Round(geshui, 2) + " where QD_YEARMONTH='" + dt01.Rows[j]["GZTZSP_YEARMONTH"].ToString().Trim() + "' and QD_STID='" + dt01.Rows[j]["GZTZ_STID"].ToString().Trim() + "' and QD_SHBH not in(select GZSH_BH from OM_GZHSB where OM_GZSCBZ='2')"; listgeshui.Add(insertgeshui); } } DBCallCommon.ExecuteTrans(listgeshui); } }
private void CaculateBzAverage() { string year = dplYear.SelectedValue; string month = dplMoth.SelectedValue; string js = "0"; string sql = "select * from TBDS_BZAVERAGE where Year='" + year + "' and Month='" + month + "' and State='2'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { string money = dt.Rows[0]["MONEY"].ToString(); js = (300 * CommonFun.ComTryDouble(money) / 2500).ToString("0.00"); lblJS.Text = "300*" + money + "/2500=" + js; hidJS.Value = js; } }
protected void ddl_jy_changed(object sender, EventArgs e) { //加油费 double jy = 0; string sql = "select MONEY FROM TBOM_CAROIL WHERE RQ LIKE '%" + ddl_jy.SelectedValue.ToString() + "%' and CARNUM='" + id + "'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { jy += CommonFun.ComTryDouble(dt.Rows[i]["MONEY"].ToString()); } } lbl_jy.Text = jy.ToString(); }
protected void btn_plexport_OnClick(object sender, EventArgs e) { string sqltext = ""; sqltext = "select CB_YearMonth,ST_WORKNO,ST_NAME,DEP_NAME,KQ_CHUQIN,KQ_CBTS,CB_TZTS,CB_BIAOZ,(CB_BIAOZ*(isnull(KQ_CBTS,0)+CB_TZTS)) as CB_MonthCB,CB_BuShangYue,(CB_BIAOZ*(isnull(KQ_CBTS,0)+CB_TZTS)+CB_BuShangYue) as CB_HeJi,CB_BeiZhu from (select * from OM_CanBu left join OM_KQTJ on (OM_CanBu.CB_STID=OM_KQTJ.KQ_ST_ID and OM_CanBu.CB_YearMonth=OM_KQTJ.KQ_DATE) left join TBDS_STAFFINFO on OM_CanBu.CB_STID=TBDS_STAFFINFO.ST_ID left join TBDS_DEPINFO on TBDS_STAFFINFO.ST_DEPID=TBDS_DEPINFO.DEP_CODE)t where " + StrWhere() + " order by DEP_NAME"; System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sqltext); string filename = "餐补统计" + DateTime.Now.ToString("yyyyMMdd") + ".xls"; HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", System.Web.HttpContext.Current.Server.UrlEncode(filename))); HttpContext.Current.Response.Clear(); //1.读取Excel到FileStream using (FileStream fs = File.OpenRead(System.Web.HttpContext.Current.Server.MapPath("餐补统计.xls"))) { IWorkbook wk = new HSSFWorkbook(fs); //创建workbook对象 ISheet sheet0 = wk.GetSheetAt(0); //创建第一个sheet for (int i = 0; i < dt.Rows.Count; i++) { IRow row = sheet0.CreateRow(i + 1); ICell cell0 = row.CreateCell(0); cell0.SetCellValue(i + 1); for (int j = 0; j < 4; j++) { row.CreateCell(j + 1).SetCellValue(dt.Rows[i][j].ToString().Trim()); } for (int k = 4; k < dt.Columns.Count - 1; k++) { row.CreateCell(k + 1).SetCellValue(CommonFun.ComTryDouble(dt.Rows[i][k].ToString().Trim())); } row.CreateCell(dt.Columns.Count).SetCellValue(dt.Rows[i][dt.Columns.Count - 1].ToString().Trim()); } for (int i = 0; i <= dt.Columns.Count; i++) { sheet0.AutoSizeColumn(i); } sheet0.ForceFormulaRecalculation = true; MemoryStream file = new MemoryStream(); wk.Write(file); HttpContext.Current.Response.BinaryWrite(file.GetBuffer()); HttpContext.Current.Response.End(); } }
private void bindrpt() { asd.dt = new DataTable(); pager_org.TableName = "(select * from OM_PXJH_SQ as a left join OM_SP as b on a.PX_SJID=b.SPFATHERID where SPZT='y' and SPLX='LSPX' union all select * from OM_PXJH_SQ as a left join OM_SP as b on a.PX_SJID1=b.SPFATHERID where SPZT='y' and SPLX='NDPXJH')t"; pager_org.PrimaryKey = "PX_ID"; pager_org.ShowFields = "* "; pager_org.OrderField = "PX_BM,PX_FS,PX_BH"; pager_org.StrWhere = StrWhere(); pager_org.OrderType = 1;//升序排列 pager_org.PageSize = 15; UCPaging1.PageSize = pager_org.PageSize; pager_org.PageIndex = UCPaging1.CurrentPage; DataTable dt = CommonFun.GetDataByPagerQueryParamWithPriKey(pager_org); CommonFun.Paging(dt, rptPXJH, UCPaging1, palNoData); asd.dt = dt; double xshj = 0; double rshj = 0; foreach (DataRow dr in dt.Rows) { xshj += CommonFun.ComTryDouble(dr["PX_SJXS"].ToString()); rshj += CommonFun.ComTryDouble(dr["PX_SJRS"].ToString()); } foreach (RepeaterItem item in rptPXJH.Controls) { if (item.ItemType == ListItemType.Footer) { ((Label)item.FindControl("XSHJ")).Text = xshj.ToString(); ((Label)item.FindControl("RSHJ")).Text = rshj.ToString(); break; } } if (palNoData.Visible) { UCPaging1.Visible = false; } else { UCPaging1.Visible = true; UCPaging1.InitPageInfo(); } }
protected void rptCGHTGL_OnItemDataBound(object sender, RepeaterItemEventArgs e)//控制审批权限 { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string htbh = ((Label)e.Item.FindControl("lbHT_XFHTBH")).Text.Trim(); string sqlgetdata = "select sum(BR_KPJE) as tolkpje from TBPC_PURBILLRECORD where BR_HTBH='" + htbh + "'"; DataTable dtgetdata = DBCallCommon.GetDTUsingSqlText(sqlgetdata); if (dtgetdata.Rows.Count > 0) { ((Label)e.Item.FindControl("lbydfpje")).Text = ((CommonFun.ComTryDouble(dtgetdata.Rows[0]["tolkpje"].ToString().Trim())) * 10000).ToString().Trim(); } DataRowView dr = (DataRowView)e.Item.DataItem; if (username != "高浩" && username != "王福泉" && username != "周文轶" && username != "姜中毅" && username != "赵宏观" && username != dr["HT_ZDR"].ToString() && username != "李洪清") { e.Item.FindControl("lbHT_HTZJ").Visible = false; } } }
protected void btnexport_click(object sender, EventArgs e) { string filename = "工资汇总" + DateTime.Now.ToString("yyyyMMdd") + ".xls"; HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", System.Web.HttpContext.Current.Server.UrlEncode(filename))); HttpContext.Current.Response.Clear(); //1.读取Excel到FileStream using (FileStream fs = File.OpenRead(System.Web.HttpContext.Current.Server.MapPath("工资汇总.xls"))) { IWorkbook wk = new HSSFWorkbook(fs); //创建workbook对象 ISheet sheet0 = wk.GetSheetAt(0); //创建第一个sheet IRow rowhead = sheet0.CreateRow(0); for (int h = 1; h < dt.Columns.Count; h++) { ICell cellhead = rowhead.CreateCell(h); cellhead.SetCellValue(dt.Columns[h].ColumnName.ToString().Trim()); } for (int i = 0; i < dt.Rows.Count; i++) { IRow row = sheet0.CreateRow(i + 1); ICell cell0 = row.CreateCell(0); cell0.SetCellValue(i + 1); for (int j = 1; j < 5; j++) { row.CreateCell(j).SetCellValue(dt.Rows[i][j].ToString().Trim()); } for (int k = 5; k < dt.Columns.Count; k++) { row.CreateCell(k).SetCellValue(CommonFun.ComTryDouble(dt.Rows[i][k].ToString().Trim())); } } for (int i = 0; i <= dt.Columns.Count; i++) { sheet0.AutoSizeColumn(i); } sheet0.ForceFormulaRecalculation = true; MemoryStream file = new MemoryStream(); wk.Write(file); HttpContext.Current.Response.BinaryWrite(file.GetBuffer()); HttpContext.Current.Response.End(); } }
private void writedata() { List <string> list_sql = new List <string>(); for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow gr = GridView1.Rows[i]; if (((TextBox)gr.FindControl("txt_mingchen")).Text != "" && ((TextBox)gr.FindControl("txt_shuliang")).Text != "") { mingchen = ((TextBox)gr.FindControl("txt_mingchen")).Text; guige = ((TextBox)gr.FindControl("txt_guige")).Text; shuliang = ((TextBox)gr.FindControl("txt_shuliang")).Text; danjia = ((TextBox)gr.FindControl("txt_danjia")).Text; danwei = ((TextBox)gr.FindControl("txt_danwei")).Text; double dj = CommonFun.ComTryDouble(danjia); double sl = CommonFun.ComTryDouble(shuliang); double zongjia = dj * sl; string zj = zongjia.ToString(); //string sqltext = "insert into OM_CARKUCUN(KC_MC,KC_GG,KC_SL,KC_DJ,KC_ZJ,KC_SJ)"; //sqltext += "values('" + mingchen + "','" + guige + "','" + shuliang + "','" + danjia + "','" + zongjia + "','" + lblInDate.Text + "')"; //list_sql.Add(sqltext); string sqltext1 = string.Format("insert into OM_CARRK_SP (SP_MC,SP_GG,SP_SL,ZDR,ZDRID,ZDR_SJ,ZDR_JY,SPR1,SPR1_ID,SPR1_JL,SPR1_JY,SPR2,SPR2_ID,SPR2_JL,SPR2_JY,SP_DJ,SP_DANWEI,SPJB,SPZT,SP_ZJ) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')", mingchen, guige, shuliang, txtZDR.Text.Trim(), hidZDRID.Value, lbZDR_SJ.Text, txtZDR_JY.Text.Trim(), txtSPR1.Text.Trim(), hidSPR1_ID.Value, "", "", txtSPR2.Text.Trim(), hidSPR2_ID.Value, "", "", danjia, danwei, rblSPJB.SelectedValue, "0", zj); list_sql.Add(sqltext1); } else { Response.Write("<script>alert('请选择“名称、数量”再提交!!!')</script>"); } } DBCallCommon.ExecuteTrans(list_sql); string _emailto = DBCallCommon.GetEmailAddressByUserID(hidSPR1_ID.Value); string _body = "车品入库审批任务:" + "\r\n制单人:" + lbl_creater.Text.Trim() + "\r\n制单日期:" + lblInDate.Text.Trim(); string _subject = "您有新的【车品入库】需要审批,请及时处理"; DBCallCommon.SendEmail(_emailto, null, null, _subject, _body); }
protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { double warning = CommonFun.ComTryDouble(e.Row.Cells[8].Text.ToString()); double storageNum = CommonFun.ComTryDouble(e.Row.Cells[11].Text.ToString()); if (storageNum < warning) { e.Row.BackColor = Color.Yellow; } } //for (int i = 1; i < 15; i++) //{ // e.Row.Cells[i].Attributes["style"] = "Cursor:hand"; // e.Row.Cells[i].Attributes.Add("title", "双击修改原始数据"); //} }
//计算基数 private string CaculateBzAverage() { string js = "0"; if (txtKhNianYue.Text != "") { string year = txtKhNianYue.Text.Split('-')[0].ToString(); string month = txtKhNianYue.Text.Split('-')[1].PadLeft(2, '0'); string sql = "select * from TBDS_BZAVERAGE where Year='" + year + "' and Month='" + month + "' and State='4'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { string money = dt.Rows[0]["MONEY"].ToString(); js = (300 * CommonFun.ComTryDouble(money) / 3500).ToString("0.00"); lblJS.Text = js; hidJS.Value = js; } } return(js); }
private List <string> checklist() { List <string> list = new List <string>(); string sql = string.Format("update OM_CARRK_SP set SPR1_JL='{0}',SPR1_JY='{1}',SPR2_JL='{2}',SPR2_JY='{3}' where ZDR_SJ='{4}'", rblSPR1_JL.SelectedValue, txtSPR1_JY.Text.Trim(), rblSPR2_JL.SelectedValue, txtSPR2_JY.Text.Trim(), id); list.Add(sql); if (asd.dts.Rows[0]["SPJB"].ToString() == "1") { if (rblSPR1_JL.SelectedValue == "y") { sql = string.Format("update OM_CARRK_SP set SPZT='y' where ZDR_SJ='{0}'", id); list.Add(sql); string sqlsp = "select * from OM_CARRK_SP where ZDR_SJ='" + id + "'"; DataTable dtsp = DBCallCommon.GetDTUsingSqlText(sqlsp); for (int i = 0; i < dtsp.Rows.Count; i++) { string mc = dtsp.Rows[i]["SP_MC"].ToString(); string gg = dtsp.Rows[i]["SP_GG"].ToString(); string sl = dtsp.Rows[i]["SP_SL"].ToString(); string dj = dtsp.Rows[i]["SP_DJ"].ToString(); string zj = dtsp.Rows[i]["SP_ZJ"].ToString(); string danwei = dtsp.Rows[i]["SP_DANWEI"].ToString(); string sqlkc = "select * from OM_CARKUCUN where KC_MC='" + mc + "' and KC_GG='" + gg + "'and KC_DJ='" + dj + "'"; DataTable dtkc = DBCallCommon.GetDTUsingSqlText(sqlkc); if (dtkc.Rows.Count == 0) { string sqltext = "insert into OM_CARKUCUN(KC_MC,KC_GG,KC_SL,KC_DJ,KC_ZJ,KC_SJ,KC_DANWEI)"; sqltext += "values('" + mc + "','" + gg + "','" + sl + "','" + dj + "','" + zj + "','" + lblInDate.Text + "','" + danwei + "')"; DBCallCommon.ExeSqlText(sqltext); } else { string kc_sl = dtkc.Rows[0]["KC_SL"].ToString(); string kc_zj = dtkc.Rows[0]["KC_ZJ"].ToString(); double a = CommonFun.ComTryDouble(sl); double b = CommonFun.ComTryDouble(kc_sl); double c = a + b; double d = CommonFun.ComTryDouble(zj); double e = CommonFun.ComTryDouble(kc_zj); double f = d + e; string sqltext = "update OM_CARKUCUN set KC_SL='" + c.ToString() + "' ,KC_ZJ='" + f.ToString() + "' where KC_MC='" + mc + "' and KC_GG='" + gg + "'and KC_DJ='" + dj + "'"; DBCallCommon.ExeSqlText(sqltext); } } } } else if (asd.dts.Rows[0]["SPJB"].ToString() == "2") { if (rblSPR1_JL.SelectedValue == "y") { sql = string.Format("update OM_CARRK_SP set SPZT='1y' where ZDR_SJ='{0}'", id); list.Add(sql); if (asd.userid == hidSPR1_ID.Value) { string _emailto = DBCallCommon.GetEmailAddressByUserID(hidSPR2_ID.Value); string _body = "车品入库审批任务:" + "\r\n制单人:" + lbl_creater.Text.Trim() + "\r\n制单日期:" + lblInDate.Text.Trim(); string _subject = "您有新的【车品入库】需要审批,请及时处理"; DBCallCommon.SendEmail(_emailto, null, null, _subject, _body); } } if (rblSPR2_JL.SelectedValue == "y") { sql = string.Format("update OM_CARRK_SP set SPZT='y' where ZDR_SJ='{0}'", id); list.Add(sql); string sqlsp = "select * from OM_CARRK_SP where ZDR_SJ='" + id + "'"; DataTable dtsp = DBCallCommon.GetDTUsingSqlText(sqlsp); for (int i = 0; i < dtsp.Rows.Count; i++) { string mc = dtsp.Rows[i]["SP_MC"].ToString(); string gg = dtsp.Rows[i]["SP_GG"].ToString(); string sl = dtsp.Rows[i]["SP_SL"].ToString(); string dj = dtsp.Rows[i]["SP_DJ"].ToString(); string zj = dtsp.Rows[i]["SP_ZJ"].ToString(); string danwei = dtsp.Rows[i]["SP_DANWEI"].ToString(); string sqlkc = "select * from OM_CARKUCUN where KC_MC='" + mc + "' and KC_GG='" + gg + "'and KC_DJ='" + dj + "'"; DataTable dtkc = DBCallCommon.GetDTUsingSqlText(sqlkc); if (dtkc.Rows.Count == 0) { string sqltext = "insert into OM_CARKUCUN(KC_MC,KC_GG,KC_SL,KC_DJ,KC_ZJ,KC_SJ,KC_DANWEI)"; sqltext += "values('" + mc + "','" + gg + "','" + sl + "','" + dj + "','" + zj + "','" + lblInDate.Text + "','" + danwei + "')"; DBCallCommon.ExeSqlText(sqltext); } else { string kc_sl = dtkc.Rows[0]["KC_SL"].ToString(); string kc_zj = dtkc.Rows[0]["KC_ZJ"].ToString(); double a = CommonFun.ComTryDouble(sl); double b = CommonFun.ComTryDouble(kc_sl); double c = a + b; double d = CommonFun.ComTryDouble(zj); double e = CommonFun.ComTryDouble(kc_zj); double f = d + e; string sqltext = "update OM_CARKUCUN set KC_SL='" + c.ToString() + "' ,KC_ZJ='" + f.ToString() + "' where KC_MC='" + mc + "' and KC_GG='" + gg + "'and KC_DJ='" + dj + "'"; DBCallCommon.ExeSqlText(sqltext); } } } } if (rblSPR1_JL.SelectedValue == "n" || rblSPR2_JL.SelectedValue == "n") { sql = string.Format("update OM_CARRK_SP set SPZT='n' where ZDR_SJ='{0}'", id); list.Add(sql); } return(list); }
//保存操作 protected void Save_Click(object sender, EventArgs e) { //此处是保存操作 List <string> sqllist = new List <string>(); string sql = ""; string Code = LabelCode.Text; //单号 string Date = TextBoxDate.Text; //日期 string APPLYID = LabelDocCode.Text; //制单人 string APPLY = LabelDoc.Text; string SHR = txtshr.Text; string SHRID = shrid.Value.Trim(); if (flag == "add") { string year = DateTime.Now.Year.ToString(); string month = DateTime.Now.Month.ToString().PadLeft(2, '0'); double benciZongJ = 0; for (int i = 0; i < GridView1.Rows.Count; i++) { string sId = ((HtmlInputHidden)this.GridView1.Rows[i].FindControl("WLCODE")).Value.Trim();//物料代码 if (sId != string.Empty) { string bm = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLBM")).Value; string name = ((TextBox)this.GridView1.Rows[i].FindControl("WLNAME")).Text.Trim(); string model = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLMODEL")).Value.Trim(); string unit = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLUNIT")).Value.Trim(); string num = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLNUM")).Value.Trim(); //申请数量 string dj = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLPRICE")).Value.Trim(); //单价 string je = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLJE")).Value.Trim(); //金额 string note = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLNOTE")).Value.Trim(); //备注 string ischange = ((DropDownList)this.GridView1.Rows[i].FindControl("ddlIsChange")).SelectedValue; string kcNum = ((HtmlInputText)this.GridView1.Rows[i].FindControl("num")).Value; //库存 Regex regMoeny = new Regex(@"^-?(\d)*((.?)(\d){1,2})?$"); Regex regNum = new Regex(@"^-?(\d)*((.?)(\d){1,2})?$"); if (regNum.IsMatch(num) && regMoeny.IsMatch(dj) && regMoeny.IsMatch(je)) { sql = "insert into TBOM_BGYPAPPLY(WLCODE,WLBM,WLNAME,WLMODEL,WLUNIT,WLPRICE,WLNUM,WLJE,WLNOTE,APPLY,APPLYID,REVIEW,REVIEWID,CODE,DATE,year,month,IsChange) values('" + sId + "','" + bm + "','" + name + "','" + model + "','" + unit + "','" + dj + "','" + num + "','" + je + "','" + note + "','" + APPLY + "','" + APPLYID + "','" + SHR + "','" + SHRID + "','" + Code + "','" + Date + "','" + year + "','" + month + "','" + ischange + "')"; sqllist.Add(sql); if (bm.IndexOf("3-") != 0) { benciZongJ += CommonFun.ComTryDouble(je); } } else { Response.Write("<script>alert('第" + i + 1 + "行数据有误,请查证后在进行保存!')</script>"); return; } if (CommonFun.ComTryDouble(num) > CommonFun.ComTryDouble(kcNum)) { Response.Write("<script>alert('库存不足,无法申请!')</script>"); return; } } } if (txtshr.Text.ToString() == "") { Response.Write("<script>alert('请选择审核人!')</script>"); return; } else { DBCallCommon.ExecuteTrans(sqllist); string _emailto = DBCallCommon.GetEmailAddressByUserID(shrid.Value); string _body = "办公用品使用审批任务:" + "\r\n编 号:" + LabelCode.Text.ToString().Trim() + "\r\n制单日期:" + TextBoxDate.Text.ToString().Trim(); string _subject = "您有新的【办公用品使用】需要审批,请及时处理:" + LabelCode.Text.ToString().Trim(); DBCallCommon.SendEmail(_emailto, null, null, _subject, _body); double BenYueSLS = 0; string sqlSum = "select sum(GET_MONEY) from View_TBOM_BGYPAPPLY where WLBM not like '3-%' and year='" + year + "' and month='" + month + "' and ST_DEPID='" + Session["UserDeptID"] + "' "; DataTable dt = DBCallCommon.GetDTUsingSqlText(sqlSum); if (dt.Rows.Count > 0) { BenYueSLS = CommonFun.ComTryDouble(dt.Rows[0][0].ToString()); } sqlSum = "select MONTH_MAX from TBOM_BGYP_Month_max where type='1' and year='" + year + "' and month='" + month + "' and DEP_CODE='" + Session["UserDeptID"] + "' "; dt = DBCallCommon.GetDTUsingSqlText(sqlSum); double byDE = 0; if (dt.Rows.Count > 0) { byDE = CommonFun.ComTryDouble(dt.Rows[0][0].ToString()); } else { sqlSum = "select MONTH_MAX from TBOM_BGYP_Month_max where type='0' and DEP_CODE='" + Session["UserDeptID"] + "' "; dt = DBCallCommon.GetDTUsingSqlText(sqlSum); if (dt.Rows.Count > 0) { byDE = CommonFun.ComTryDouble(dt.Rows[0][0].ToString()); } } if (benciZongJ + BenYueSLS > byDE) { Response.Write("<script>alert('提示:本月申请总计【" + (benciZongJ + BenYueSLS).ToString() + "】已超本月额度【" + byDE + "】,申请仍会通过,请注意!');window.location='OM_BgypApplyMain.aspx';</script>"); } else { Response.Redirect("OM_BgypApplyMain.aspx"); } } } if (flag == "verify") { sql = "update TBOM_BGYPAPPLY set REVIEWSTATE='" + drop_view.SelectedValue.ToString() + "' WHERE CODE='" + Code + "'"; DBCallCommon.ExeSqlText(sql); if (drop_view.SelectedValue.ToString() == "2") { string _emailto = DBCallCommon.GetEmailAddressByUserID("181"); string _body = "办公用品使用审批任务:" + "\r\n编 号:" + LabelCode.Text.ToString().Trim() + "\r\n制单日期:" + TextBoxDate.Text.ToString().Trim(); string _subject = "您有新的【办公用品使用】需要添加实领数,请及时处理:" + LabelCode.Text.ToString().Trim(); DBCallCommon.SendEmail(_emailto, null, null, _subject, _body); } Response.Redirect("OM_BgypApplyMain.aspx"); } if (flag == "addsls") { for (int i = 0; i < GridView1.Rows.Count; i++) { string sId = ((HtmlInputHidden)this.GridView1.Rows[i].FindControl("WLCODE")).Value.Trim();//物料代码 if (sId != string.Empty) { string sls = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLSLS")).Value.Trim(); string get_money = ((HtmlInputText)this.GridView1.Rows[i].FindControl("GET_MONEY")).Value.Trim(); string kcNum = ((HtmlInputText)this.GridView1.Rows[i].FindControl("num")).Value; string StoreId = ((HtmlInputHidden)this.GridView1.Rows[i].FindControl("hidStoreId")).Value; string isCalculate = ((DropDownList)this.GridView1.Rows[i].FindControl("ddlIsCal")).SelectedValue; string IsChange = ((DropDownList)this.GridView1.Rows[i].FindControl("ddlIsChange")).SelectedValue; if (CommonFun.ComTryDouble(sls) <= CommonFun.ComTryDouble(kcNum)) { if (sls == "") { sql = "update TBOM_BGYPAPPLY set WLSLS='',GET_MONEY='',IsCalculate='" + isCalculate + "',IsChange='" + IsChange + "' WHERE CODE='" + Code + "' AND WLCODE='" + sId + "'"; } else { sql = "update TBOM_BGYPAPPLY set WLSLS='" + CommonFun.ComTryInt(sls) + "',GET_MONEY='" + CommonFun.ComTryDouble(get_money) + "',IsCalculate='" + isCalculate + "',IsChange='" + IsChange + "' WHERE CODE='" + Code + "' AND WLCODE='" + sId + "'"; } sqllist.Add(sql); sql = "update TBOM_BGYP_STORE set num=num-" + CommonFun.ComTryInt(sls) + ",price=price-unPrice*" + CommonFun.ComTryInt(sls) + " WHERE Id='" + StoreId + "'"; sqllist.Add(sql); } else { Response.Write("<script>alert('库存不足,无法领取!')</script>"); return; } } else { Response.Write("<script>alert('物料编码不能为零!')</script>"); return; } } DBCallCommon.ExecuteTrans(sqllist); Response.Redirect("OM_BgypApplyMain.aspx"); } if (flag == "mod") { sql = "delete from TBOM_BGYPAPPLY where CODE='" + Code + "'"; sqllist.Add(sql); for (int i = 0; i < GridView1.Rows.Count; i++) { string sId = ((HtmlInputHidden)this.GridView1.Rows[i].FindControl("WLCODE")).Value.Trim();//物料代码 if (sId != string.Empty) { string bm = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLBM")).Value; string name = ((TextBox)this.GridView1.Rows[i].FindControl("WLNAME")).Text.Trim(); string model = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLMODEL")).Value.Trim(); string unit = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLUNIT")).Value.Trim(); string num = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLNUM")).Value.Trim(); //数量 string dj = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLPRICE")).Value.Trim(); //数量 string je = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLJE")).Value.Trim(); //金额 string note = ((HtmlInputText)this.GridView1.Rows[i].FindControl("WLNOTE")).Value.Trim(); //备注 string ischange = ((DropDownList)this.GridView1.Rows[i].FindControl("ddlIsChange")).SelectedValue; Regex regMoeny = new Regex(@"^-?(\d)*((.?)(\d){1,2})?$"); Regex regNum = new Regex(@"^-?(\d)*((.?)(\d){1,2})?$"); if (regNum.IsMatch(num) && regMoeny.IsMatch(dj) && regMoeny.IsMatch(je)) { sql = "insert into TBOM_BGYPAPPLY(WLCODE,WLBM,WLNAME,WLMODEL,WLUNIT,WLPRICE,WLNUM,WLJE,WLNOTE,APPLY,APPLYID,REVIEW,REVIEWID,CODE,DATE,IsChange) values('" + sId + "','" + bm + "','" + name + "','" + model + "','" + unit + "','" + dj + "','" + num + "','" + je + "','" + note + "','" + APPLY + "','" + APPLYID + "','" + SHR + "','" + SHRID + "','" + Code + "','" + Date + "','" + ischange + "')"; sqllist.Add(sql); } else { Response.Write("<script>alert('第" + i + 1 + "行数据有误,请查证后在进行保存!')</script>"); return; } } } DBCallCommon.ExecuteTrans(sqllist); Response.Redirect("OM_BgypApplyMain.aspx"); } }
//保存操作 protected void Save_Click(object sender, EventArgs e) { //此处是保存操作 List <string> sqllist = new List <string>(); List <string> liststorege = new List <string>(); //更新库存 List <string> listinsert = new List <string>(); //插入没有的数据 string sql = ""; string Code = LabelCode.Text; //单号 string Date = TextBoxDate.Text; //日期 string DocCode = LabelDocCode.Text; //制单人单号 sql = "DELETE FROM TBOM_BGYP_IN WHERE Code='" + Code + "'"; sqllist.Add(sql); //1为备库 sql = "INSERT INTO TBOM_BGYP_IN (Code, Maker, MakerNM, MakeTime) values('" + Code + "','" + LabelDocCode.Text + "','" + LabelDoc.Text + "','" + TextBoxDate.Text + "')"; sqllist.Add(sql); sql = "DELETE FROM TBOM_BGYP_IN_DETAIL WHERE wId='" + Code + "'"; sqllist.Add(sql); int count_add = 0; for (int i = 0; i < GridView1.Rows.Count; i++) { string sId = ((HtmlInputHidden)this.GridView1.Rows[i].FindControl("sId")).Value.Trim();//物料代码 string code_CG = ((HtmlInputHidden)this.GridView1.Rows[i].FindControl("CODE")).Value.Trim(); string txt_maid = ((TextBox)this.GridView1.Rows[i].FindControl("maId")).Text.ToString(); string sql_CG = "update TBOM_BGYPPCAPPLYINFO set STATE_rk='1' where CODE='" + code_CG + "' and WLBM='" + txt_maid + "'"; sqllist.Add(sql_CG); // DBCallCommon.ExeSqlText(sql_CG); string input_name = ((HtmlInputText)this.GridView1.Rows[i].FindControl("name")).Value.Trim(); if (txt_maid != "" && input_name != "") { count_add++; } if (sId != string.Empty) { string num = ((HtmlInputText)this.GridView1.Rows[i].FindControl("num")).Value.Trim(); //数量 string dj = ((HtmlInputText)this.GridView1.Rows[i].FindControl("uprice_dj")).Value.Trim() == "" ? "0" : ((HtmlInputText)this.GridView1.Rows[i].FindControl("uprice_dj")).Value.Trim(); //单价 double djia = CommonFun.ComTryDouble(dj); string je = ((HtmlInputText)this.GridView1.Rows[i].FindControl("price_je")).Value.Trim() == "" ? "0" : ((HtmlInputText)this.GridView1.Rows[i].FindControl("price_je")).Value.Trim(); //金额 string note = ((HtmlInputText)this.GridView1.Rows[i].FindControl("note")).Value.Trim(); //备注 string ordernum = ((Label)this.GridView1.Rows[i].FindControl("lblCode")).Text.Trim(); //订单号 Regex regMoeny = new Regex(@"^-?(\d)*((.?)(\d){1,2})?$"); Regex regNum = new Regex(@"^-?(\d)*((.?)(\d){1,2})?$"); if (regNum.IsMatch(num) && regMoeny.IsMatch(dj) && regMoeny.IsMatch(je)) { sql = "insert into TBOM_BGYP_IN_DETAIL(wId, sId, uprice, price, num, note,ordercode) values('" + Code + "'," + sId + "," + dj + "," + je + "," + num + ",'" + note + "','" + ordernum + "')"; sqllist.Add(sql); sql = "select * from TBOM_BGYP_STORE where mId=" + sId; //sql = "select num,price,Id from TBOM_BGYP_STORE where mId=" + sId + " and unPrice =" + dj + ""; //unPrice DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { float zongnum = float.Parse(dt.Rows[0]["num"].ToString()) + float.Parse(num); float zongje = float.Parse(dt.Rows[0]["price"].ToString()) + float.Parse(je); string id = dt.Rows[0]["Id"].ToString(); if (zongnum > 0 || zongnum == 0) { if (zongnum > 0) { sql = "update TBOM_BGYP_STORE set num=" + zongnum + ",unPrice='" + zongje / zongnum + "',price=" + zongje + " where Id=" + id; } else { sql = "update TBOM_BGYP_STORE set num=" + zongnum + ",unPrice='" + dj + "',price=" + zongje + " where Id=" + id; } liststorege.Clear(); liststorege.Add(sql); DBCallCommon.ExecuteTrans(liststorege); } else { Response.Write("<script>alert('第" + i + 1 + "行数据有误,库存无足够数量!')</script>"); return; } } else { if (float.Parse(num) > 0) { sql = "insert into TBOM_BGYP_STORE(mId, price, num, unPrice) values('" + sId + "'," + (CommonFun.ComTryDouble(num) * CommonFun.ComTryDouble(dj)).ToString() + "," + num + "," + dj + ")"; listinsert.Clear(); listinsert.Add(sql); DBCallCommon.ExecuteTrans(listinsert); } else { Response.Write("<script>alert('第" + i + 1 + "行数据有误,库存无足够数量!')</script>"); return; } } } else { Response.Write("<script>alert('第" + i + 1 + "行数据有误,请查证后在进行保存!')</script>"); return; } } } DBCallCommon.ExecuteTrans(sqllist); if (count_add == 0) { string sql_delete = "DELETE FROM TBOM_BGYP_IN WHERE Code='" + Code + "'"; DBCallCommon.ExeSqlText(sql_delete); string sql_delete1 = "DELETE FROM TBOM_BGYP_IN_DETAIL WHERE wId='" + Code + "'"; DBCallCommon.ExeSqlText(sql_delete1); } Response.Redirect("OM_BGYP_In_List.aspx"); }
//审批 protected void btnAudit_Click(object sender, EventArgs e) { string sql = ""; string state = ""; if (action == "add" || action == "edit") { sql = " update TBDS_KaoHe_JXList set State='1' where Context='" + hidConext.Value + "'"; DBCallCommon.ExeSqlText(sql); //邮件提醒 string sprid = ""; string sptitle = ""; string spcontent = ""; sprid = firstid.Value.Trim(); sptitle = "职能部门绩效工资审批"; spcontent = txtKhNianYue.Text.Trim() + "职能部门绩效工资需要您审批,请登录查看!"; DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(sprid), new List <string>(), new List <string>(), sptitle, spcontent); Response.Write("<script>alert('保存成功!');window.location.href='OM_KaoHe_JXGZ_List.aspx';</script>"); } else if (action == "audit") { //提示计算工资 foreach (RepeaterItem item in Det_Repeater.Items) { if (((TextBox)item.FindControl("txtMoney")).Text.Trim() == "0" || ((TextBox)item.FindControl("txtMoney")).Text.Trim() == "0.0" || ((TextBox)item.FindControl("txtMoney")).Text.Trim() == "0.00") { Response.Write("<script>alert('存在绩效工资为0的项,请先输入比例后计算绩效工资!')</script>"); return; } } if (CommonFun.ComTryDouble(hidZongHeNew.Value) > CommonFun.ComTryDouble(txtZonghe.Text)) { Response.Write("<script>alert('调整后工资总和应小于等于原工资总和!')</script>"); return; } if (rblResult1.SelectedIndex == -1) { Response.Write("<script>alert('请选择审核结果!')</script>"); return; } else { List <string> list = new List <string>(); if (rblResult1.SelectedValue == "0") { state = "2"; foreach (RepeaterItem item in Det_Repeater.Items) { string Money = ((TextBox)item.FindControl("txtMoney")).Text; string Id = ((HtmlInputHidden)item.FindControl("hidId")).Value; sql = string.Format("update TBDS_KaoHe_JXDetail set Money='" + Money + "' where Id='" + Id + "'"); list.Add(sql); } } else if (rblResult1.SelectedValue == "1") { state = "3"; } sql = "update TBDS_KaoHe_JXList set state='" + state + "',RESULTA='" + rblResult1.SelectedValue + "',TIMEA='" + DateTime.Now.ToString() + "',OPTIONA='" + first_opinion.Text.Trim() + "',YuE='" + (CommonFun.ComTryDouble(txtZonghe.Text) - CommonFun.ComTryDouble(hidZongHeNew.Value)).ToString("0.00") + "' where Context='" + hidConext.Value + "'"; list.Add(sql); DBCallCommon.ExecuteTrans(list); Response.Write("<script>alert('保存成功!');window.location.href='OM_KaoHe_JXGZ_List.aspx';</script>"); } } }
protected void btnCacuJX_Click(object sender, EventArgs e) { List <string> sql_list = new List <string>(); if (txtKhNianYue.Text == "") { Response.Write("<script>alert('请选择考核年月!')</script>"); return; } string year = txtKhNianYue.Text.Split('-')[0].ToString(); string month = txtKhNianYue.Text.Split('-')[1].PadLeft(2, '0'); string bl1 = txtHP.Text.Trim(); string bl2 = txtLD.Text.Trim(); string bl = bl1 + ":" + bl2; //if (CommonFun.ComTryInt(bl1) + CommonFun.ComTryInt(bl2) != 100) //{ // Response.Write("<script>alert('请输入正确的比例,使和为100!!!')</script>"); // return; //} for (int i = 0; i < Det_Repeater.Items.Count; i++) { string Id = ((HtmlInputHidden)Det_Repeater.Items[i].FindControl("hidId")).Value.Trim(); string scoreHp = ((System.Web.UI.WebControls.TextBox)Det_Repeater.Items[i].FindControl("txtScoreHP")).Text.Trim(); string txtlScoreLD = ((System.Web.UI.WebControls.TextBox)Det_Repeater.Items[i].FindControl("txtlScoreLD")).Text.Trim(); string lblScoreZong = ((HtmlInputHidden)Det_Repeater.Items[i].FindControl("hidZong")).Value.Trim(); string txtNote = ((System.Web.UI.WebControls.TextBox)Det_Repeater.Items[i].FindControl("txtNote")).Text.Trim(); string stID = ((HtmlInputHidden)Det_Repeater.Items[i].FindControl("hidStId")).Value; //Id, Kh_Year, Kh_Month, Kh_ScoreHP, Kh_ScoreLD, Kh_ScoreTotal, Kh_BL, Kh_Id, Kh_BeiZhu, ST_NAME, ST_SEQUEN, ST_GENDER, DEP_NAME, POSITION, ST_WORKNO string sqlText = ""; if (bl1 == "" || bl2 == "") { } else { sqlText = "update TBDS_KaoHeTotal set Kh_ScoreHP='" + CommonFun.ComTryDecimal(scoreHp) + "',Kh_ScoreLD='" + CommonFun.ComTryDecimal(txtlScoreLD) + "',Kh_ScoreTotal='" + CommonFun.ComTryDecimal(lblScoreZong) + "',Kh_BL='" + bl + "' where Kh_Year='" + year + "' and Kh_Month='" + month + "' and Kh_Id='" + stID + "'"; sql_list.Add(sqlText); } sqlText = "update TBDS_KaoHe_JXDetail set Score='" + CommonFun.ComTryDecimal(lblScoreZong) + "', Note='" + txtNote + "' where JxYear='" + year + "' and JxMonth='" + month + "' and ST_ID='" + stID + "'"; sql_list.Add(sqlText); } //更新 DBCallCommon.ExecuteTrans(sql_list); CaculateBzAverage(); string js = CaculateBzAverage(); string sql = "select DepartId,Score from View_TBDS_KaoheDepartMonth where DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and State='2' and DepartId='" + ddl_Depart.SelectedValue + "'"; DataTable dtPart = DBCallCommon.GetDTUsingSqlText(sql); if (dtPart.Rows.Count > 0) { for (int i = 0; i < dtPart.Rows.Count; i++) { string depId = dtPart.Rows[i]["DepartId"].ToString(); string score = dtPart.Rows[i]["Score"].ToString(); if (ddl_Depart.SelectedValue == "12") { sql = "select sum((case when GangWeiXiShu='' or GangWeiXiShu is null then 1.00 else GangWeiXiShu end)*(case when Score is null then 0.0 else Score end)) from TBDS_KaoHe_JXDetail where JxYear='" + year + "' and JxMonth='" + month + "' and PosName <> '部长' and PosName <> '副部长' and PosName not like '%总监%' and PosName not like '%总经理助理兼部长%' and Context='" + hidConext.Value + "'"; } else { sql = "select sum((case when GangWeiXiShu='' or GangWeiXiShu is null then 1.00 else GangWeiXiShu end)*(case when Score is null then 0.0 else Score end)) from TBDS_KaoHe_JXDetail where JxYear='" + year + "' and JxMonth='" + month + "' and PosName <> '部长' and PosName not like '%总监%' and PosName not like '%总经理助理兼部长%' and Context='" + hidConext.Value + "'"; } DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { double zongXishu = CommonFun.ComTryDouble(dt.Rows[0][0].ToString()); //double zongDeiFen = CommonFun.ComTryDouble(dt.Rows[0][1].ToString()); //if (zongDeiFen == 0) //{ // zongDeiFen = 1.0; //} double zonggongzi = CommonFun.ComTryDouble(txtZonghe.Text.Trim()); if (ddl_Depart.SelectedValue == "12") { sql = "update TBDS_KaoHe_JXDetail set Money=case when PosName = '部长' or PosName = '副部长' or PosName like '%总监%' or PosName like '%总经理助理兼部长%' then " + CommonFun.ComTryDouble(js) * CommonFun.ComTryDouble(score) / 100.0 + "*GangWeiXiShu else " + zonggongzi / zongXishu + "*cast(Score as float)*GangWeiXiShu end where JxYear='" + year + "' and JxMonth='" + month + "' and Context='" + hidConext.Value + "' "; } else { sql = "update TBDS_KaoHe_JXDetail set Money=case when PosName = '部长' or PosName like '%总监%' or PosName like '%总经理助理兼部长%' then " + CommonFun.ComTryDouble(js) * CommonFun.ComTryDouble(score) / 100.0 + "*GangWeiXiShu else " + zonggongzi / zongXishu + "*cast(Score as float)*GangWeiXiShu end where JxYear='" + year + "' and JxMonth='" + month + "' and Context='" + hidConext.Value + "' "; } DBCallCommon.ExeSqlText(sql); } } } ShowData(hidConext.Value); }
protected void Tb_newmarid_Textchanged(object sender, EventArgs e) { string marid = ""; string marname = ""; string sqltext = ""; DataTable glotb = new DataTable(); TextBox Tb_newmarid = (TextBox)sender; //定义TextBox RepeaterItem Reitem = (RepeaterItem)Tb_newmarid.Parent; //repeater中的item if (Tb_newmarid.Text.ToString().Contains("|")) { marid = Tb_newmarid.Text.Substring(0, Tb_newmarid.Text.ToString().IndexOf("|")); marname = Tb_newmarid.Text.Substring(Tb_newmarid.Text.ToString().IndexOf("|") + 1); sqltext = "SELECT MNAME,GUIGE,CAIZHI,GB,PURCUNIT,FUZHUUNIT,MWEIGHT FROM TBMA_MATERIAL WHERE ID='" + marid + "' ORDER BY ID"; glotb = DBCallCommon.GetDTUsingSqlText(sqltext); if (glotb.Rows.Count > 0) { Tb_newmarid.Text = marid; ((Label)Reitem.FindControl("MP_NEWMARNAME")).Text = glotb.Rows[0]["MNAME"].ToString(); ((Label)Reitem.FindControl("MP_NEWGUIGE")).Text = glotb.Rows[0]["GUIGE"].ToString(); ((Label)Reitem.FindControl("MP_NEWCAIZHI")).Text = glotb.Rows[0]["CAIZHI"].ToString(); ((Label)Reitem.FindControl("MP_NEWGUOBIAO")).Text = glotb.Rows[0]["GB"].ToString(); ((Label)Reitem.FindControl("MP_NEWUNIT")).Text = glotb.Rows[0]["PURCUNIT"].ToString(); ((Label)Reitem.FindControl("MP_NEWFZUNIT")).Text = glotb.Rows[0]["FUZHUUNIT"].ToString(); //单位换算 //主单位千克,理论重量不为0,数量与辅助数量均不为0 if (glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "kg" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim()))).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim()))).ToString("0.0000").Trim(); } } //主单位吨,理论重量不为0,数量与辅助数量均不为0 else if (glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "T" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) / 1000).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) / 1000).ToString("0.0000").Trim(); } } //辅助单位千克,理论重量不为0,数量与辅助数量均不为0 else if (glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "kg" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim()))).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim()))).ToString("0.0000").Trim(); } } //辅助单位吨,理论重量不为0,数量与辅助数量均不为0 else if (glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "T" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) / 1000).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) / 1000).ToString("0.0000").Trim(); } } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('输入的物料编码不存在,请重新输入!');", true); } } else { if (!(Tb_newmarid.Text == "" || Tb_newmarid.Text == DBNull.Value.ToString())) { sqltext = "SELECT ID,MNAME,GUIGE,CAIZHI,GB,PURCUNIT,FUZHUUNIT,MWEIGHT FROM TBMA_MATERIAL WHERE ID='" + Tb_newmarid.Text.Replace(" ", "") + "' OR HMCODE='" + Tb_newmarid.Text.Replace(" ", "") + "' ORDER BY ID"; glotb = DBCallCommon.GetDTUsingSqlText(sqltext); if (glotb.Rows.Count == 1) { ((TextBox)Reitem.FindControl("MP_NEWMARID")).Text = glotb.Rows[0]["ID"].ToString(); ((Label)Reitem.FindControl("MP_NEWMARNAME")).Text = glotb.Rows[0]["MNAME"].ToString(); ((Label)Reitem.FindControl("MP_NEWGUIGE")).Text = glotb.Rows[0]["GUIGE"].ToString(); ((Label)Reitem.FindControl("MP_NEWCAIZHI")).Text = glotb.Rows[0]["CAIZHI"].ToString(); ((Label)Reitem.FindControl("MP_NEWGUOBIAO")).Text = glotb.Rows[0]["GB"].ToString(); ((Label)Reitem.FindControl("MP_NEWUNIT")).Text = glotb.Rows[0]["PURCUNIT"].ToString(); ((Label)Reitem.FindControl("MP_NEWFZUNIT")).Text = glotb.Rows[0]["FUZHUUNIT"].ToString(); //单位换算 //主单位千克,理论重量不为0,数量与辅助数量均不为0 if (glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "kg" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim()))).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim()))).ToString("0.0000").Trim(); } } //主单位吨,理论重量不为0,数量与辅助数量均不为0 else if (glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "T" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) / 1000).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) / 1000).ToString("0.0000").Trim(); } } //辅助单位千克,理论重量不为0,数量与辅助数量均不为0 else if (glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "kg" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim()))).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim()))).ToString("0.0000").Trim(); } } //辅助单位吨,理论重量不为0,数量与辅助数量均不为0 else if (glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() == "T" && glotb.Rows[0]["MWEIGHT"].ToString().Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "0" && ((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim() != "" && ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text.Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "" && glotb.Rows[0]["PURCUNIT"].ToString().Trim() != "张" && glotb.Rows[0]["FUZHUUNIT"].ToString().Trim() != "张") { if ((glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "平米" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "m2" || glotb.Rows[0]["PURCUNIT"].ToString().Trim() == "M2") && (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) > 0) { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["GUIGE"].ToString().Trim())) / 1000).ToString("0.0000").Trim();//板 } else { ((TextBox)Reitem.FindControl("TMP_NEWNUMB")).Text = ((CommonFun.ComTryDouble(((TextBox)Reitem.FindControl("TMP_NEWNUMA")).Text.Trim())) * (CommonFun.ComTryDouble(glotb.Rows[0]["MWEIGHT"].ToString().Trim())) / 1000).ToString("0.0000").Trim(); } } } else { if (glotb.Rows.Count > 1) { Tb_newmarid.Text = ""; Tb_newmarid.Focus(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('输入的物料编码不完整,请重新输入!');", true); return; } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('输入的物料编码不存在,请重新输入!');", true); } } } else { Tb_newmarid.Focus(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('输入的物料编码为空,请重新输入!');", true); } } }
protected void btnsubmit_Click(object sender, EventArgs e) { string dep = ddl_Depart.SelectedValue; string pos = ""; string name = txtName.Text.Trim(); List <string> list = new List <string>(); int bz = CommonFun.ComTryInt(txtBl1.Text.Trim()) + CommonFun.ComTryInt(txtBl2.Text.Trim()) + CommonFun.ComTryInt(txtBl3.Text.Trim()) + CommonFun.ComTryInt(txtBl4.Text.Trim()); if (bz != 100) { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请填写正确的权重!');", true); return; } string bl1 = txtBl1.Text.Trim() == "" ? "0" : txtBl1.Text.Trim(); string bl2 = txtBl2.Text.Trim() == "" ? "0" : txtBl2.Text.Trim(); string bl3 = txtBl3.Text.Trim() == "" ? "0" : txtBl3.Text.Trim(); string bl4 = txtBl4.Text.Trim() == "" ? "0" : txtBl4.Text.Trim(); string bl = bl1 + "|" + bl2 + "|" + bl3 + "|" + bl4; if (dep != "00" && pos != "00" && name != "") { if (action == "add") { if (Det_Repeater.Items.Count != 0) { string fkey = DateTime.Now.ToString("yyyyMMddhhmmss"); string sql = string.Format("insert into TBDS_KaoHeMBList(kh_Dep,Kh_Type,kh_Fkey,kh_AddId,kh_Time,kh_State,kh_Name,kh_BL,kh_Type1,kh_Note) values('{0}','{1}','{2}','{3}','{4}','0','{5}','{6}','{7}','{8}')", dep, pos, fkey, hidAddPer.Value, DateTime.Now.ToString("yyyy-MM-dd"), name, bl, ddlType.SelectedValue, txtPFBZ.Text); list.Add(sql); List <string> col = new List <string>(); for (int i = 1; i < 6; i++) { col.Add(((ITextControl)Det_Repeater.Controls[0].FindControl("kh_Col" + i)).Text); } sql = string.Format("insert into TBDS_KaoHeCol values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", col[0], col[1], col[2], col[3], col[4], "", "", "", "", "", "", "", fkey); list.Add(sql); double sum = 0; for (int i = 0; i < Det_Repeater.Items.Count; i++) { List <string> txt = new List <string>(); for (int j = 1; j < 7; j++) { txt.Add(((ITextControl)Det_Repeater.Items[i].FindControl("txt" + j)).Text.Replace(Convert.ToString((char)13), "<br />")); } sql = string.Format("insert into TBDS_KaoHeMuB values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')", i + 1, fkey, txt[0], txt[1], txt[2], txt[3], txt[4], "", "", "", "", "", "", "", txt[5]); list.Add(sql); sum += CommonFun.ComTryDouble(txt[5]); } if (sum != 100) { ScriptManager.RegisterStartupScript(this.Page, GetType(), "1", "alert('子项权重之和需等于100!')", true); return; } DBCallCommon.ExecuteTrans(list); ScriptManager.RegisterStartupScript(this.Page, GetType(), "1", "alert('添加成功!');window.location.href='OM_KaoHeMuBList.aspx'", true); } else { ScriptManager.RegisterStartupScript(this.Page, GetType(), "2", "alert('未添加任何行!');", true); } } else if (action == "edit") { string sql = string.Format("update TBDS_KaoHeMBList set kh_Dep='{0}',kh_AddId='{1}',kh_Time='{2}',kh_name='{3}',kh_bl='{4}',kh_Type1='{5}',kh_Note='{7}' where kh_Fkey='{6}'", ddl_Depart.SelectedValue.ToString(), hidAddPer.Value, DateTime.Now.ToString("yyyy-MM-dd"), txtName.Text.Trim(), bl, ddlType.SelectedValue, key, txtPFBZ.Text); list.Add(sql); List <string> col = new List <string>(); for (int i = 1; i < 6; i++) { col.Add(((ITextControl)Det_Repeater.Controls[0].FindControl("kh_Col" + i)).Text); } sql = string.Format("update TBDS_KaoHeCol set kh_Col1='{0}',kh_Col2='{1}',kh_Col3='{2}',kh_Col4='{3}',kh_Col5='{4}',kh_Col6='{5}',kh_Col7='{6}',kh_Col8='{7}',kh_Col9='{8}',kh_Col10='{9}',kh_Col11='{10}',kh_Col12='{11}' where kh_fkey='{12}'", col[0], col[1], col[2], col[3], col[4], "", "", "", "", "", "", "", key); list.Add(sql); sql = "delete from TBDS_KaoHeMuB where kh_Fkey='" + key + "'"; list.Add(sql); for (int i = 0; i < Det_Repeater.Items.Count; i++) { List <string> txt = new List <string>(); for (int j = 1; j < 7; j++) { txt.Add(((ITextControl)Det_Repeater.Items[i].FindControl("txt" + j)).Text); } sql = string.Format("insert into TBDS_KaoHeMuB values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')", i + 1, key, txt[0], txt[1], txt[2], txt[3], txt[4], "", "", "", "", "", "", "", txt[5]); list.Add(sql); } DBCallCommon.ExecuteTrans(list); ScriptManager.RegisterStartupScript(this.Page, GetType(), "1", "alert('编辑成功!');window.location.href='OM_KaoHeMuBList.aspx'", true); } } else { //Response.Write("<script>alert('请检查部门和职位!');</script>"); ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请检查部门、职位和模板名称!');", true); } }
private void ExportDataItem(System.Data.DataTable objdt) { string filename = "工资修改记录" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xls"; HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", System.Web.HttpContext.Current.Server.UrlEncode(filename))); HttpContext.Current.Response.Clear(); //1.读取Excel到FileStream using (FileStream fs = File.OpenRead(System.Web.HttpContext.Current.Server.MapPath("工资修改记录.xls"))) { IWorkbook wk = new HSSFWorkbook(fs); ISheet sheet0 = wk.GetSheetAt(0); for (int i = 0; i < objdt.Rows.Count; i++) { IRow row = sheet0.CreateRow(i + 2); row.CreateCell(0).SetCellValue(Convert.ToString(i + 1)); row.CreateCell(1).SetCellValue(objdt.Rows[i]["QD_YEARMONTH"].ToString().Trim()); row.CreateCell(2).SetCellValue(objdt.Rows[i]["ST_WORKNO"].ToString().Trim()); row.CreateCell(3).SetCellValue(objdt.Rows[i]["ST_NAME"].ToString().Trim()); row.CreateCell(4).SetCellValue(objdt.Rows[i]["QD_HTZT"].ToString().Trim()); row.CreateCell(5).SetCellValue(objdt.Rows[i]["QD_QFBS"].ToString().Trim()); row.CreateCell(6).SetCellValue(objdt.Rows[i]["DEP_NAME"].ToString().Trim()); row.CreateCell(7).SetCellValue(objdt.Rows[i]["ST_DEPID1"].ToString().Trim()); row.CreateCell(8).SetCellValue(objdt.Rows[i]["DEP_NAME_POSITION"].ToString().Trim()); row.CreateCell(9).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_CHUQIN"].ToString().Trim())); row.CreateCell(10).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_JRJIAB"].ToString().Trim())); row.CreateCell(11).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_ZMJBAN"].ToString().Trim())); row.CreateCell(12).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_YSGZ"].ToString().Trim())); row.CreateCell(13).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_YEBAN"].ToString().Trim())); row.CreateCell(14).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_BINGJ"].ToString().Trim())); row.CreateCell(15).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_SHIJ"].ToString().Trim())); row.CreateCell(16).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["KQ_NIANX"].ToString().Trim())); row.CreateCell(17).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_JCGZ"].ToString().Trim())); row.CreateCell(18).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_GZGL"].ToString().Trim())); row.CreateCell(19).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_GDGZ"].ToString().Trim())); row.CreateCell(20).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_JXGZ"].ToString().Trim())); row.CreateCell(21).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_JiangLi"].ToString().Trim())); row.CreateCell(22).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_BingJiaGZ"].ToString().Trim())); row.CreateCell(23).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_JiaBanGZ"].ToString().Trim())); row.CreateCell(24).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_ZYBF"].ToString().Trim())); row.CreateCell(25).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_NianJiaGZ"].ToString().Trim())); row.CreateCell(26).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_YKGW"].ToString().Trim())); row.CreateCell(27).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_TZBF"].ToString().Trim())); row.CreateCell(28).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_TZBK"].ToString().Trim())); row.CreateCell(29).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_JTBT"].ToString().Trim())); row.CreateCell(30).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_FSJW"].ToString().Trim())); row.CreateCell(31).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_CLBT"].ToString().Trim())); row.CreateCell(32).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_QTFY"].ToString().Trim())); row.CreateCell(33).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_YFHJ"].ToString().Trim()));//应发合计 row.CreateCell(34).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_YLBX"].ToString().Trim())); row.CreateCell(35).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_SYBX"].ToString().Trim())); row.CreateCell(36).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_YiLiaoBX"].ToString().Trim())); row.CreateCell(37).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_DEJZ"].ToString().Trim())); row.CreateCell(38).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_BuBX"].ToString().Trim())); row.CreateCell(39).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_GJJ"].ToString().Trim())); row.CreateCell(40).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_BGJJ"].ToString().Trim())); row.CreateCell(41).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_ShuiDian"].ToString().Trim())); row.CreateCell(42).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_KOUXIANG"].ToString().Trim())); row.CreateCell(43).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_GeShui"].ToString().Trim())); row.CreateCell(44).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_DaiKouXJ"].ToString().Trim())); //代扣小计 row.CreateCell(45).SetCellValue(CommonFun.ComTryDouble(objdt.Rows[i]["QD_ShiFaJE"].ToString().Trim())); //实发金额 row.CreateCell(46).SetCellValue(objdt.Rows[i]["QD_edittime"].ToString()); row.CreateCell(47).SetCellValue(objdt.Rows[i]["QD_editname"].ToString()); row.CreateCell(48).SetCellValue(objdt.Rows[i]["QD_NOTE"].ToString()); } for (int i = 0; i <= objdt.Columns.Count; i++) { sheet0.AutoSizeColumn(i); } sheet0.ForceFormulaRecalculation = true; MemoryStream file = new MemoryStream(); wk.Write(file); HttpContext.Current.Response.BinaryWrite(file.GetBuffer()); HttpContext.Current.Response.End(); } }