private void bindGrid() { pager_org.PageIndex = UCPaging1.CurrentPage; System.Data.DataTable dt = CommonFun.GetDataByPagerQueryParamGroupBy(pager_org); CommonFun.Paging(dt, rptProNumCost, UCPaging1, palNoData); int zongji = 0; if (palNoData.Visible) { UCPaging1.Visible = false; heji.Visible = false; zonge.Visible = false; } else { UCPaging1.Visible = true; UCPaging1.InitPageInfo(); //分页控件中要显示的控件 heji.Visible = true; zonge.Visible = true; } for (int i = 0; i < dt.Rows.Count; i++) { zongji += (CommonFun.ComTryInt(dt.Rows[i]["CB_HeJihj"].ToString())); } heji.Text = zongji.ToString(); }
protected void btnBaofei_Click(object sender, EventArgs e) { int times = 0; string stid = ""; foreach (RepeaterItem rptitem in Repeater1.Items) { System.Web.UI.WebControls.CheckBox cbx = (System.Web.UI.WebControls.CheckBox)rptitem.FindControl("CheckBox1"); System.Web.UI.WebControls.Label lbid = (System.Web.UI.WebControls.Label)rptitem.FindControl("lbID"); if (cbx.Checked == true) { stid += CommonFun.ComTryInt(lbid.Text.ToString()) + ","; times++; } } if (times == 0) { Response.Write("<script>alert('请勾选报废的非固定资产项!')</script>"); return; } else { Response.Write("<script>window.open('OM_FGdzcBaofei_Detail.aspx?action=add&id=" + stid + "','_blank','height=500px,width=1200px')</script>"); } }
/// <summary> /// 分页初始化 /// </summary> /// <param name="where"></param> private void InitPager() { string lastyear = ""; string lastmonth = ""; try { if (CommonFun.ComTryInt(ddlMonth.SelectedValue.ToString().Trim()) == 1) { lastyear = (CommonFun.ComTryInt(ddlYear.SelectedValue.ToString().Trim()) - 1).ToString().Trim(); lastmonth = "12"; } else { lastyear = ddlYear.SelectedValue.ToString().Trim(); lastmonth = (CommonFun.ComTryInt(ddlMonth.SelectedValue.ToString().Trim()) - 1).ToString("00").Trim(); } } catch { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('获取年月份出错!');", true); return; } pager_org.TableName = "(select *,zzZT=case when ST_ZHENG between ('" + lastyear + "-" + lastmonth + "-21') and ('" + ddlYear.SelectedValue.ToString().Trim() + "-" + ddlMonth.SelectedValue.ToString().Trim() + "-20') then '1' else '0' end from OM_Canbusp left join OM_CanBu on OM_Canbusp.bh=OM_CanBu.detailbh 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"; pager_org.PrimaryKey = "CB_ID"; pager_org.ShowFields = "*,(CB_BIAOZ*(isnull(KQ_CBTS,0)+CB_TZTS)) as CB_MonthCB,(CB_BIAOZ*(isnull(KQ_CBTS,0)+CB_TZTS)+CB_BuShangYue) as CB_HeJi "; pager_org.OrderField = "DEP_NAME,CB_YearMonth"; pager_org.StrWhere = StrWhere(); pager_org.OrderType = 0;//升序排列 pager_org.PageSize = 230; }
protected void rptstaffchange_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView dr = (DataRowView)e.Item.DataItem; Label lbLasDeptNum = (Label)e.Item.FindControl("lbLasDeptNum"); Label lbSC_DepNum = (Label)e.Item.FindControl("lbSC_DepNum"); Label lbSC_IncNum = (Label)e.Item.FindControl("lbSC_IncNum"); Label lbSC_DecNum = (Label)e.Item.FindControl("lbSC_DecNum"); lbLasDeptNum.Text = (CommonFun.ComTryInt(lbSC_DepNum.Text.Trim()) - CommonFun.ComTryInt(lbSC_IncNum.Text.Trim()) + CommonFun.ComTryInt(lbSC_DecNum.Text.Trim())).ToString(); if (lbSC_IncNum.Text != "0") { lbSC_IncNum.ForeColor = System.Drawing.Color.FromName("#9E4DB3"); } if (lbSC_DecNum.Text != "0") { lbSC_DecNum.ForeColor = System.Drawing.Color.Red; } //if (e.Item.ItemIndex != -1) //{ // ((TextBox)e.Item.FindControl("txtSC_IncPersonInfo")).Text = SubStr(dr["SC_IncPersonInfo"].ToString(), 22); // ((TextBox)e.Item.FindControl("txtSC_DecPersonInfo")).Text = SubStr(dr["SC_DecPersonInfo"].ToString(), 22); //} } }
private string GetHTBH() { string htbh; string sql = "select max(HT_HTBH) from EQU_GXHT "; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows[0][0].ToString() == "") { htbh = "ZCZJSB-" + DateTime.Now.Year.ToString() + "-001"; } else { string[] a = dt.Rows[0][0].ToString().Split('-'); int b = CommonFun.ComTryInt(a[2]) + 1; if (a[1] == DateTime.Now.Year.ToString()) { htbh = a[0] + "-" + a[1] + "-" + b.ToString().PadLeft(3, '0'); } else { htbh = a[0] + "-" + DateTime.Now.Year.ToString() + "001"; } } return(htbh); }
//绑定数据 private void binddata() { string sql = "select * from AuditNew as a left join PowerContent as b on a.auditno=b.contentno left join View_TBDS_STAFFINFO as c on b.stid=c.ST_ID where auditno='" + auditno + "'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { txt_contentno.Text = dt.Rows[0]["contentno"].ToString().Trim(); stname.Text = dt.Rows[0]["stname"].ToString().Trim(); stid.Text = dt.Rows[0]["stid"].ToString().Trim(); txt_dep.Text = dt.Rows[0]["DEP_NAME"].ToString().Trim(); hiddepid.Value = dt.Rows[0]["ST_DEPID"].ToString().Trim(); DEP_POSITION.Text = dt.Rows[0]["DEP_POSITION"].ToString().Trim(); role.Text = dt.Rows[0]["R_NAME"].ToString().Trim(); txt_content.Text = dt.Rows[0]["powercontent"].ToString().Trim(); string sqlgetroleid = "select R_ID from ROLE_INFO where R_NAME=" + dt.Rows[0]["R_NAME"].ToString().Trim() + ""; DataTable dtgetroleid = DBCallCommon.GetDTUsingSqlText(sqlgetroleid); if (dtgetroleid.Rows.Count > 0) { roleid = CommonFun.ComTryInt(dtgetroleid.Rows[0]["R_ID"].ToString().Trim()); } else { roleid = 0; } } }
/// <summary> /// 根据QueryString初始化页面信息 /// </summary> protected void InitInfo() { if (Request.QueryString["id"] != null) //批号 KI/AZ/1-1.JSB MP/WPP/01 { mp_no.Value = Request.QueryString["id"]; fields = Request.QueryString["id"].ToString().Split('.'); tsa_id.Text = fields[0].ToString(); status.Value = "0";// 审核状态 审核状态 初始化为0,1为保存,2为提交,3为一级驳回,4为一级通过,5为二级驳回,6为二级通过,7为三级驳回,8为三级通过 btn_concel.Visible = true; CheckBox2.Visible = true; btnreturn.Text = "返回继续勾选"; } #region else { if (Request.QueryString["mpdetail_id"] != null)//未提交、审核中或审核通过进入 批号 KI/AZ/1-1.JSB MP/WPP/01.6 { fields = Request.QueryString["mpdetail_id"].ToString().Split('.'); tsa_id.Text = fields[0].ToString(); mp_no.Value = fields[0].ToString() + '.' + fields[1].ToString(); status.Value = fields[2].ToString(); btn_concel.Visible = true; CheckBox2.Visible = true; if (CommonFun.ComTryInt(status.Value) > 1) //已提交审核 { Response.Redirect("TM_MP_Require_Audit.aspx?id=" + mp_no.Value); } } else if (Request.QueryString["mpedit_id"] != null)//驳回后进入 批号 KI/AZ/1-1.JSB MP/WPP/01.7 { fields = Request.QueryString["mpedit_id"].ToString().Split('.'); tsa_id.Text = fields[0].ToString(); mp_no.Value = fields[0].ToString() + '.' + fields[1].ToString(); status.Value = fields[2].ToString(); btn_concel.Visible = true; CheckBox2.Visible = true; } } #endregion sqlText = "select TSA_PJID,TSA_ENGNAME,CM_PROJ "; sqlText += "from View_TM_TaskAssign where TSA_ID='" + tsa_id.Text + "'"; SqlDataReader dr = DBCallCommon.GetDRUsingSqlText(sqlText); if (dr.Read()) { lab_contract.Text = dr[0].ToString(); lab_engname.Text = dr[1].ToString(); lab_proname.Text = dr[2].ToString(); } dr.Close(); this.InitList(); this.GetNameData(ddlMarName); this.GetCaiZhiData(ddlMarCaiZhi); this.GetGuiGeData(ddlMarGuiGe); UCPagingMS.CurrentPage = 1; InitVarMS(); bindGridMS(); }
protected void btnsave_Click(object sender, EventArgs e) { List <string> list = new List <string>(); int num = 0; if (tb_ycdate.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请选择用餐时间!');", true); return; } if (rad_yctype.SelectedValue != "1" && rad_yctype.SelectedValue != "2") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请选择用餐类型!');", true); return; } if (tbycrens.Text.Trim() == "" || tbycguige.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请填写用餐规格和用餐人数!');", true); return; } string strspbh = ""; string sqlzdbh = "select max(eatbh) as eatbhmax from OM_EATNEW where eatbh like '" + DateTime.Now.ToString("yyyyMMdd").Trim() + "%'"; System.Data.DataTable dtzdbh = DBCallCommon.GetDTUsingSqlText(sqlzdbh); if (dtzdbh.Rows.Count > 0 && dtzdbh.Rows[0]["eatbhmax"].ToString().Trim().Length >= 12) { strspbh = DateTime.Now.ToString("yyyyMMdd").Trim() + "-" + (CommonFun.ComTryInt(dtzdbh.Rows[0]["eatbhmax"].ToString().Trim().Substring(9, 3)) + 1).ToString("000").Trim(); } else { strspbh = DateTime.Now.ToString("yyyyMMdd").Trim() + "-" + "001"; } string sqlinsertsh = "insert into OM_EATNEW(eatbh,eatyctime,eattype,eatsqrid,eatsqrname,eatsqtime,eatsqrphone,eatsqrnote) values('" + strspbh + "','" + tb_ycdate.Text.Trim() + "','" + rad_yctype.SelectedValue.ToString().Trim() + "','" + Session["UserID"].ToString().Trim() + "','" + Session["UserName"].ToString().Trim() + "','" + lbsqdate.Text.Trim() + "','" + txt_phone.Text.Trim() + "','" + txt_contents.Text.Trim() + "')"; list.Add(sqlinsertsh); string sqlinsertyc = "insert into OM_EATNEWDETAIL(detailbh,detailnum,detailprice,detailifYP) values('" + strspbh + "'," + CommonFun.ComTryDecimal(tbycrens.Text.Trim()) + "," + CommonFun.ComTryDecimal(tbycguige.Text.Trim()) + ",'2')"; list.Add(sqlinsertyc); for (int j = 0; j < Det_Repeater.Items.Count; j++) { if (CommonFun.ComTryDecimal(((TextBox)Det_Repeater.Items[j].FindControl("txt3")).Text.Trim()) > 0 || CommonFun.ComTryDecimal(((TextBox)Det_Repeater.Items[j].FindControl("txt5")).Text.Trim()) > 0) { TextBox txt1 = (TextBox)Det_Repeater.Items[j].FindControl("txt1"); TextBox txt2 = (TextBox)Det_Repeater.Items[j].FindControl("txt2"); TextBox txt3 = (TextBox)Det_Repeater.Items[j].FindControl("txt3"); TextBox txt4 = (TextBox)Det_Repeater.Items[j].FindControl("txt4"); TextBox txt5 = (TextBox)Det_Repeater.Items[j].FindControl("txt5"); string sqlinsertdetail = "insert into OM_EATNEWDETAIL(detailbh,detailthing,detailclass,detailnum,detailunit,detailprice,detailifYP) values('" + strspbh + "','" + txt1.Text.Trim() + "','" + txt2.Text.Trim() + "'," + CommonFun.ComTryDecimal(txt3.Text.Trim()) + ",'" + txt4.Text.Trim() + "'," + CommonFun.ComTryDecimal(txt5.Text.Trim()) + ",'1')"; list.Add(sqlinsertdetail); } } DBCallCommon.ExecuteTrans(list); Response.Redirect("OM_EATSPdetailnew.aspx?spid=" + strspbh); }
private void databind() { pager.TableName = "OM_StaffChange"; pager.PrimaryKey = ""; pager.ShowFields = "SC_STDepID,SC_STDep,SC_DepNum,SC_YearMonth,SC_IncNum,SC_DecNum,SC_IncPersonInfo,SC_DecPersonInfo,SC_ChangeInfo,SC_Note"; pager.OrderField = "SC_STDepID,SC_YearMonth"; pager.StrWhere = StrWhere(); pager.OrderType = 0; pager.PageSize = int.Parse(ddl_pageno.SelectedValue); UCPaging1.PageSize = pager.PageSize; pager.PageIndex = UCPaging1.CurrentPage; DataTable dt = CommonFun.GetDataByPagerQueryParam(pager); CommonFun.Paging(dt, rptstaffchange, UCPaging1, palNoData); if (palNoData.Visible) { UCPaging1.Visible = false;//如果筛选结果没有,则UCPaging不显示 prow.Visible = false; } else { UCPaging1.Visible = true; prow.Visible = true; UCPaging1.InitPageInfo(); } int lbnownum = 0; int lbincnum = 0; int lbdecnum = 0; Label lb_lastnum = (Label)rptstaffchange.Controls[rptstaffchange.Controls.Count - 1].FindControl("lb_lastnum"); Label lb_nownum = (Label)rptstaffchange.Controls[rptstaffchange.Controls.Count - 1].FindControl("lb_nownum"); Label lb_incnum = (Label)rptstaffchange.Controls[rptstaffchange.Controls.Count - 1].FindControl("lb_incnum"); Label lb_decnum = (Label)rptstaffchange.Controls[rptstaffchange.Controls.Count - 1].FindControl("lb_decnum"); for (int i = 0; i < rptstaffchange.Items.Count; i++) { Label s = (Label)rptstaffchange.Items[i].FindControl("lbXuHao"); Label lbSC_DepNum = (Label)rptstaffchange.Items[i].FindControl("lbSC_DepNum"); Label lbSC_IncNum = (Label)rptstaffchange.Items[i].FindControl("lbSC_IncNum"); Label lbSC_DecNum = (Label)rptstaffchange.Items[i].FindControl("lbSC_DecNum"); s.Text = (i + 1 + (pager.PageIndex - 1) * UCPaging1.PageSize).ToString(); lbnownum += CommonFun.ComTryInt(lbSC_DepNum.Text.ToString().Trim()); lbincnum += CommonFun.ComTryInt(lbSC_IncNum.Text.ToString().Trim()); lbdecnum += CommonFun.ComTryInt(lbSC_DecNum.Text.ToString().Trim()); } lb_nownum.Text = lbnownum.ToString(); lb_incnum.Text = lbincnum.ToString(); lb_decnum.Text = lbdecnum.ToString(); lb_lastnum.Text = (lbnownum - lbincnum + lbdecnum).ToString(); CellsMerge(rptstaffchange); }
//下推出库 protected void btnPush_OnClick(object sender, EventArgs e) { string tsaid = ""; string sql = ""; string sql2 = ""; int j = 0; for (int i = 0; i < Repeater1.Items.Count; i++) { if (((CheckBox)Repeater1.Items[i].FindControl("CheckBox1")).Checked == true) { tsaid = ((Label)Repeater1.Items[i].FindControl("lbCPQROut_TaskID")).Text; string engname = ((Label)Repeater1.Items[i].FindControl("lblEngname")).Text; string zongxu = ((Label)Repeater1.Items[i].FindControl("CPQROut_Zongxu")).Text; string map = ((Label)Repeater1.Items[i].FindControl("lblMap")).Text; int kcnum = Convert.ToInt32(((Label)Repeater1.Items[i].FindControl("lblkcnum")).Text); int cknum = CommonFun.ComTryInt(((TextBox)Repeater1.Items[i].FindControl("txtCPQROut_Num")).Text); string fid = ((Label)Repeater1.Items[i].FindControl("CM_FID")).Text; string bianhao = ((Label)Repeater1.Items[i].FindControl("CM_BIANHAO")).Text; string singlenum = ((Label)Repeater1.Items[i].FindControl("KC_SINGNUM")).Text; string yfnum = ((Label)Repeater1.Items[i].FindControl("txtYfnum")).Text; int yf = CommonFun.ComTryInt(yfnum); if (cknum == 0) { string alert = "<script>alert('请填写出库数量!!!')</script>"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", alert, false); return; } if (cknum > kcnum || cknum > yf) { string alert = "<script>alert('出库数量不得大于已比价数量或库存数量!!!')</script>"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", alert, false); return; } sql = " insert into TBMP_FINISHED_OUT (TFO_ZONGXU,TFO_DOCNUM,TFO_ENGNAME,TFO_MAP,TSA_ID,TFO_KCNUM,TFO_CKNUM,TFO_BIANHAO,TFO_FID,TFO_SINGNUM,QROutUniqCode) VALUES ('" + zongxu + "','" + docnum.Value.ToString() + "','" + engname + "','" + map + "','" + tsaid + "'," + kcnum + "," + cknum + ",'" + bianhao + "','" + fid + "','" + singlenum + "'," + Convert.ToInt32(((Label)Repeater1.Items[i].FindControl("CPQROut_ID")).Text.ToString()) + ")"; list.Add(sql); sql2 = "update midTable_Finished_QROut set CPQROut_State='1' where CPQROut_ID=" + Convert.ToInt32(((Label)Repeater1.Items[i].FindControl("CPQROut_ID")).Text.ToString()) + ""; list.Add(sql2); j++; } } if (j < 1) { string alert = "<script>alert('请选择下推条目!!!')</script>"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", alert, false); return; } DBCallCommon.ExecuteTrans(list); Response.Redirect("~/PM_Data/PM_Finished_OUTBILL.aspx?FLAG=PUSH&docnum=" + docnum.Value.ToString() + ""); }
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); } }
//绑定数据 private void binddata() { id_htys = Request.QueryString["id_htys"].ToString().Trim(); string sql = "select * from FM_HTYUSUAN where id_htys=" + CommonFun.ComTryInt(id_htys) + ""; System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { dplYear.SelectedValue = dt.Rows[0]["ht_year"].ToString().Trim().Substring(0, 4); ht_addname.Text = dt.Rows[0]["ht_addname"].ToString().Trim(); ht_addtime.Text = dt.Rows[0]["ht_addtime"].ToString().Trim(); ht_yusuanhte.Text = dt.Rows[0]["ht_yusuanhte"].ToString().Trim(); ht_note.Text = dt.Rows[0]["ht_note"].ToString().Trim(); } }
private string GetDH() { string dh = ""; string sql = "select max(DH) as DH from TBOM_GDZCTRANSFER where TRANSFTYPE='0'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows[0][0].ToString() == "") { dh = "G-ZY00001"; } else { dh = dt.Rows[0][0].ToString().Split('Y')[0] + "Y" + (CommonFun.ComTryInt(dt.Rows[0][0].ToString().Split('Y')[1]) + 1).ToString().PadLeft(5, '0'); } return(dh); }//获取转移单号
//绑定申请编号 protected string GetCode() { string TD_code = ""; string sql = "select max(TD_code) as TD_code from OM_TravelDelay"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows[0][0].ToString() == "") { TD_code = "TD_SQ" + DateTime.Now.ToString("yyMMdd") + "00001"; } else { TD_code = "TD_SQ" + DateTime.Now.ToString("yyMMdd") + (CommonFun.ComTryInt(dt.Rows[0][0].ToString().Substring(11, 5)) + 1).ToString().PadLeft(5, '0'); } return(TD_code); }
//绑定审批编号 protected string GetSPBH() { string SPBH = ""; string sql = "select max(SPBH) as SPBH from OM_GDZCBFSP"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows[0][0].ToString() == "") { SPBH = "G-BF" + DateTime.Now.ToString("yyMMdd") + "-0001"; } else { SPBH = "G-BF" + DateTime.Now.ToString("yyMMdd") + "-" + (CommonFun.ComTryInt(dt.Rows[0][0].ToString().Split('-')[2]) + 1).ToString().PadLeft(4, '0'); } return(SPBH); }
/// <summary> /// 插入数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btninsert_Click(object sender, EventArgs e) { DataTable dt = this.GetDataFromGrid(false); int a = CommonFun.ComTryInt(txtNum.Text.Trim()); for (int i = 0; i < a; i++) { DataRow newRow = dt.NewRow(); dt.Rows.Add(newRow); } this.GridView1.DataSource = dt; this.GridView1.DataBind(); txtNum.Text = ""; }
private void GetDepJXGZ() { string Id = Session["UserID"].ToString().Trim(); string year = DateTime.Now.AddMonths(-1).Year.ToString(); string month = DateTime.Now.AddMonths(-1).Month.ToString().PadLeft(2, '0'); string sql = "select count(1) from TBDS_KaoHe_JXList where (state='1' and SPRID='" + Id + "') or (state='3' and ZDRID='" + Id + "') "; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); sql = "select count(1) from (select d.Id from dbo.TBDS_KaoheDeaprtMonth as a left join dbo.TBDS_BZAVERAGE as b on a.Year=b.Year and a.Month=b.Month left join dbo.TBDS_KaoheDeaprtMonth_Detail as c on a.Context=c.Context left join dbo.TBDS_KaoHe_JXList as d on a.Year=d.Year and a.Month=b.Month and c.DepartId=d.DepId where a.state='2' and b.state='4' and a.Month='" + month + "' and a.Year='" + year + "' and (d.state='2' or d.state='0' or d.state='1' or d.state is null))e where e.Id is null and '人力资源专员' in (" + Session["UserGroup"].ToString() + ")"; DataTable dt1 = DBCallCommon.GetDTUsingSqlText(sql); int i = CommonFun.ComTryInt(dt.Rows[0][0].ToString()) + CommonFun.ComTryInt(dt1.Rows[0][0].ToString()); if (i.ToString() != "0") { lblDepJXGZ.Text = "(" + i.ToString() + ")"; } }
private void bindrpt() { pager_org.TableName = "PM_CPFYJSD"; pager_org.PrimaryKey = "JS_ID"; pager_org.ShowFields = "* "; pager_org.OrderField = "JS_ID"; pager_org.StrWhere = StrWhere(); pager_org.OrderType = 1;//升序排列 pager_org.PageSize = CommonFun.ComTryInt(ddl_pagesize.SelectedItem.Text.ToString()); UCPaging1.PageSize = pager_org.PageSize; pager_org.PageIndex = UCPaging1.CurrentPage; System.Data.DataTable dt = CommonFun.GetDataByPagerQueryParamWithPriKey(pager_org); CommonFun.Paging(dt, rptJSDGL, UCPaging1, NoDataPane); //计算总金额 string sqlzong = "select * from PM_CPFYJSD where " + StrWhere() + " "; System.Data.DataTable dt1 = DBCallCommon.GetDTUsingSqlText(sqlzong); double tot_money = 0; for (int i = 0; i < dt1.Rows.Count; i++) { if (dt1.Rows[i]["JS_HSJE"].ToString() == "") { tot_money += 0; } else { tot_money += Convert.ToDouble(dt1.Rows[i]["JS_HSJE"].ToString()); } } lb_select_money.Text = tot_money.ToString("0.00"); if (NoDataPane.Visible) { UCPaging1.Visible = false; } else { UCPaging1.Visible = true; UCPaging1.InitPageInfo(); } }
private void rensjs() { int renshu = 0; if (lbstid1.Text.Trim() != "" && txtST_NAME1.Text.Trim()!="") { renshu = renshu + 1; } if (lbstid2.Text.Trim() != "" && txtST_NAME2.Text.Trim() != "") { renshu = renshu + 1; } if (lbstid3.Text.Trim() != "" && txtST_NAME3.Text.Trim() != "") { renshu = renshu + 1; } if (lbstid4.Text.Trim() != "" && txtST_NAME4.Text.Trim() != "") { renshu = renshu + 1; } lbxyrs.Text = renshu.ToString().Trim(); lbkrzsl.Text = (CommonFun.ComTryInt(tbrjrs.Text.Trim()) - renshu).ToString().Trim(); }
protected void btnCreat_Click(object sender, EventArgs e) { string year = dplYear.SelectedValue; string month = dplMoth.SelectedValue; string bl1 = txtHP.Text.Trim(); string bl2 = txtLD.Text.Trim(); string bl = bl1 + ":" + bl2; List <string> list = new List <string>(); if (CommonFun.ComTryInt(bl1) + CommonFun.ComTryInt(bl2) != 100) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请输入正确的比例,使和为100!!!');", true); return; } if (dplYear.SelectedIndex == 0 || dplMoth.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择年月!!!');", true); return; } string sql = "delete a from TBDS_KaoHeTotal as a left join dbo.TBDS_STAFFINFO as b on a.Kh_Id=b.ST_ID where b.ST_DEPID='" + ddl_Depart.SelectedValue + "' and a.Kh_Year='" + year + "' and a.Kh_Month='" + month + "'"; list.Add(sql); if (bl1 != "0") { sql = "insert into dbo.TBDS_KaoHeTotal select '" + year + "','" + month + "','0',case when kh_Score is null then '0' else kh_Score end ,'0','" + bl + "',ST_ID,'' from dbo.TBDS_STAFFINFO as a left join (select * from dbo.TBDS_KaoHeList where (Kh_Type='人员月度考核' or Kh_Type is null) and Kh_Year='" + year + "' and Kh_Month='" + month + "' and Kh_State in ('6','7'))b on a.ST_ID=b.kh_Id where ST_PD='0' and ST_DEPID='" + ddl_Depart.SelectedValue + "'"; } else { sql = "insert into dbo.TBDS_KaoHeTotal select '" + year + "','" + month + "','0',case when kh_Score is null then '0' else kh_Score end ,(isnull(kh_Score,0.00))/100.00*(" + CommonFun.ComTryDecimal(bl2) + "),'" + bl + "',ST_ID,'' from dbo.TBDS_STAFFINFO as a left join (select * from dbo.TBDS_KaoHeList where (Kh_Type='人员月度考核' or Kh_Type is null) and Kh_Year='" + year + "' and Kh_Month='" + month + "' and Kh_State in ('6','7'))b on a.ST_ID=b.kh_Id where ST_PD='0' and ST_DEPID='" + ddl_Depart.SelectedValue + "'"; } list.Add(sql); DBCallCommon.ExecuteTrans(list); //更新总分 bindGrid(); }
protected void Textname_TextChanged(object sender, EventArgs e) { int num = (sender as TextBox).Text.Trim().IndexOf("|", 0); TextBox Tb_newstid = (TextBox)sender; if (num > 0) { string st_id = (sender as TextBox).Text.Trim().Substring(0, num); string sqlText = "select * from View_TBDS_STAFFINFO where ST_ID='" + st_id + "'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sqlText); if (dt.Rows.Count > 0) { stname.Text = dt.Rows[0]["ST_NAME"].ToString().Trim(); stid.Text = dt.Rows[0]["ST_ID"].ToString().Trim(); txt_dep.Text = dt.Rows[0]["DEP_NAME"].ToString().Trim(); hiddepid.Value = dt.Rows[0]["ST_DEPID"].ToString().Trim(); DEP_POSITION.Text = dt.Rows[0]["DEP_POSITION"].ToString().Trim(); role.Text = dt.Rows[0]["R_NAME"].ToString().Trim(); string sqlgetroleid = "select R_ID from ROLE_INFO where R_NAME=" + dt.Rows[0]["R_NAME"].ToString().Trim() + ""; DataTable dtgetroleid = DBCallCommon.GetDTUsingSqlText(sqlgetroleid); if (dtgetroleid.Rows.Count > 0) { roleid = CommonFun.ComTryInt(dtgetroleid.Rows[0]["R_ID"].ToString().Trim()); } else { roleid = 0; } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('人员不存在,请重新输入!');", true); } } }
private void zhuanzhnegtx() { if (dplYear.SelectedIndex != 0 && dplMoth.SelectedIndex != 0) { string strnamezhengry = ""; string lastyear = ""; string lastmonth = ""; try { if (CommonFun.ComTryInt(dplMoth.SelectedValue.ToString().Trim()) == 1) { lastyear = (CommonFun.ComTryInt(dplYear.SelectedValue.ToString().Trim()) - 1).ToString().Trim(); lastmonth = "12"; } else { lastyear = dplYear.SelectedValue.ToString().Trim(); lastmonth = (CommonFun.ComTryInt(dplMoth.SelectedValue.ToString().Trim()) - 1).ToString("00").Trim(); } } catch { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('获取年月份出错!');", true); return; } string sqlzhengry = "select ST_NAME from TBDS_STAFFINFO where ST_ZHENG>='" + lastyear + "-" + lastmonth + "-21' and ST_ZHENG<='" + dplYear.SelectedValue.ToString().Trim() + "-" + dplMoth.SelectedValue.ToString().Trim() + "-20' and ST_ID in(select QD_STID from OM_GZQD where QD_YEARMONTH='" + dplYear.SelectedValue.ToString().Trim() + "-" + dplMoth.SelectedValue.ToString().Trim() + "')"; System.Data.DataTable dtzhengry = DBCallCommon.GetDTUsingSqlText(sqlzhengry); if (dtzhengry.Rows.Count > 0) { for (int m = 0; m < dtzhengry.Rows.Count; m++) { strnamezhengry += dtzhengry.Rows[m]["ST_NAME"].ToString().Trim() + ","; } strnamezhengry = strnamezhengry.Substring(0, strnamezhengry.Length - 1); ipt_zhuanzheng.Value = strnamezhengry; ipt_zhuanzheng.Attributes.Add("title", strnamezhengry); } } }
protected void btnexport_Click(object sender, EventArgs e) { string sql = "select DEP_NAME,eatyctime,detailnum,detailprice,(detailnum*detailprice) as detailmoney,eattype,eatsqrname,eatsqtime,eatsqrphone,eatsqrnote,case baoxiaostate when 'Y' then '是' else '否' end as baoxiaostate,case detailifYP when '2' then '用餐' else '饮品' end as detailifYP from (select * from OM_EATNEW as a left join OM_EATNEWDETAIL as b on a.eatbh=b.detailbh left join TBDS_STAFFINFO as c on a.eatsqrid=c.ST_ID left join TBDS_DEPINFO as d on c.ST_DEPID=d.DEP_CODE)t where " + StrWhere() + " order by eatbh DESC"; System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); string filename = "用餐申请导出.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(); using (FileStream fs = File.OpenRead(System.Web.HttpContext.Current.Server.MapPath("用餐申请导出模板.xls"))) { IWorkbook wk = new HSSFWorkbook(fs);//创建workbook对象 ISheet sheet1 = wk.GetSheetAt(0); int zonge = CommonFun.ComTryInt(lb_totalmoney.Text); for (int i = 0; i < dt.Rows.Count; i++) { IRow row = sheet1.CreateRow(i + 1); ICell cell0 = row.CreateCell(0); cell0.SetCellValue(i + 1); for (int j = 0; j < dt.Columns.Count; j++) { string str = dt.Rows[i][j].ToString(); row.CreateCell(j + 1).SetCellValue(str); } } IRow row2 = sheet1.CreateRow(dt.Rows.Count + 1); row2.CreateCell(5).SetCellValue("总额:" + zonge.ToString()); for (int r = 0; r <= dt.Columns.Count; r++) { sheet1.AutoSizeColumn(r); } sheet1.ForceFormulaRecalculation = true; MemoryStream file = new MemoryStream(); wk.Write(file); HttpContext.Current.Response.BinaryWrite(file.GetBuffer()); HttpContext.Current.Response.End(); } }
//保存操作 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 btnSave_OnClick(object sender, EventArgs e) { if (txtName.Text.Trim() == "") { Response.Write("<script>alert('名称不能为空!!!');window.close();</script>"); return; } else { string method1 = method.Value; string sqltext1 = ""; if (method1 == "New") { string sqltext000 = "select * from TBQC_TARGET_LIST where TARGET_NAME='" + txtName.Text.Trim() + "'"; DataTable dt000 = DBCallCommon.GetDTUsingSqlText(sqltext000); if (dt000.Rows.Count > 0) { Response.Write("<script>alert('已存在该名称的数据!!!');window.close();</script>"); return; } else { sqlText = "insert into TBQC_TARGET_LIST values ('" + txtName.Text.Trim() + "','" + txtBZ.Text.Trim() + "')"; } } else { sqlText = "update TBQC_TARGET_LIST set TARGET_NAME='" + txtName.Text.Trim() + "',TARGET_NOTE='" + txtBZ.Text.Trim() + "' where TARGET_ID=" + hidTargetId.Value; } try { DBCallCommon.ExeSqlText(sqlText); if (method1 == "New") { if (ddl_loaddata.SelectedIndex != 0) { string sqltext001 = "select * from TBQC_TARGET_LIST where TARGET_NAME='" + txtName.Text.Trim() + "'"; DataTable dt001 = DBCallCommon.GetDTUsingSqlText(sqltext001); if (dt001.Rows.Count > 0) { sqltext1 = "insert into TBQC_TARGET_DETAIL(TARGET_DEPID,TARGET_TIXI,TARGET_MUBIAO,TARGET_MANAGER,TARGET_FID,TARGET_TJBMID) select TARGET_DEPID,TARGET_TIXI,TARGET_MUBIAO,TARGET_MANAGER," + CommonFun.ComTryInt(dt001.Rows[0]["TARGET_ID"].ToString().Trim()) + ",TARGET_TJBMID from TBQC_TARGET_DETAIL where TARGET_FID=" + CommonFun.ComTryInt(ddl_loaddata.SelectedValue.Trim()) + ""; DBCallCommon.ExeSqlText(sqltext1); } } } Response.Write("<script>alert('数据更新成功!!!');window.close();</script>"); } catch (Exception) { Response.Write("<script>alert('程序出错请稍后再试!!!');window.close();</script>"); } } }
protected void btnCreatJx_Click(object sender, EventArgs e) { if (txtKhNianYue.Text == "") { Response.Write("<script>alert('请选择考核年月!')</script>"); return; } string creatContext = DateTime.Now.ToString("yyyyMMddhhmmss"); hidConext.Value = creatContext; string year = txtKhNianYue.Text.Split('-')[0].ToString(); string month = txtKhNianYue.Text.Split('-')[1].PadLeft(2, '0'); List <string> list = new List <string>(); string sql = "select * from View_TBDS_KaoheDepartMonth where DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and State='2'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count == 0) { Response.Write("<script>alert('未找到当月部门绩效考核数据!!!')</script>"); return; } sql = "select * from TBDS_BZAVERAGE where Year='" + year + "' and Month='" + month + "' and State='4'"; dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count == 0) { Response.Write("<script>alert('未找到一线班组平均工资数据!!!')</script>"); return; } sql = "select * from TBDS_KaoHeTotal as a left join TBDS_STAFFINFO as b on a.Kh_Id=b.ST_ID where Kh_Year='" + year + "' and Kh_Month='" + month + "' and b.ST_DEPID='" + ddl_Depart.SelectedValue + "'"; DataTable dtCount = DBCallCommon.GetDTUsingSqlText(sql); if (dtCount.Rows.Count > 0) { } else { sql = "insert into dbo.TBDS_KaoHeTotal select '" + year + "','" + month + "','0',case when kh_Score is null then '0' when kh_Score='' then '0' else kh_Score end ,'0','',ST_ID,'' from dbo.TBDS_STAFFINFO as a left join (select * from dbo.TBDS_KaoHeList where (Kh_Type='人员月度考核' or Kh_Type is null) and Kh_Year='" + year + "' and Kh_Month='" + month + "')b on a.ST_ID=b.kh_Id where ST_PD in ('0','2') and ST_DEPID='" + ddl_Depart.SelectedValue + "'"; list.Add(sql); } string lastYear = ""; string lastMonth = ""; if (month == "01") { lastMonth = "12"; lastYear = (CommonFun.ComTryInt(year) - 1).ToString(); } else { lastMonth = (CommonFun.ComTryInt(month) - 1).ToString().PadLeft(2, '0'); lastYear = year; } //sql = "delete a from TBDS_KaoHeTotal as a left join dbo.TBDS_STAFFINFO as b on a.Kh_Id=b.ST_ID where b.ST_DEPID='" + ddl_Depart.SelectedValue + "' and a.Kh_Year='" + year + "' and a.Kh_Month='" + month + "'"; //list.Add(sql); //sql = "delete from TBDS_KaoHe_JXDetail where DEP_ID='" + ddl_Depart.SelectedValue + "' and JxYear='" + year + "' and JxMonth='" + month + "'"; //list.Add(sql); string sqlifexist = "select '" + creatContext + "','','0',d.Score,ST_GANGWEIXISHU,'0',DEP_POSITION,c.ST_ID,c.ST_NAME,ST_DEPID,c.DEP_NAME,DepMonth_Year,DepMonth_Month from dbo.TBDS_KaoHe_JXList as a left join dbo.TBDS_KaoHe_JXDetail as b on a.ConText=b.Context left join View_TBDS_STAFFINFO as c on b.ST_ID=c.ST_ID inner join View_TBDS_KaoheDepartMonth as d on c.ST_DEPID=d.DepartId where d.state='2' and DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and Year='" + lastYear + "' and Month='" + lastMonth + "' and ST_DEPID='" + ddl_Depart.SelectedValue + "' and ST_PD in ('0','2')"; DataTable dtifexist = DBCallCommon.GetDTUsingSqlText(sqlifexist); sql = " insert into TBDS_KaoHe_JXDetail select ''"; if (dtifexist.Rows.Count > 0) { sql = "insert into TBDS_KaoHe_JXDetail select '" + creatContext + "','','0',d.Score,ST_GANGWEIXISHU,'0',DEP_POSITION,c.ST_ID,c.ST_NAME,ST_DEPID,c.DEP_NAME,DepMonth_Year,DepMonth_Month from dbo.TBDS_KaoHe_JXList as a left join dbo.TBDS_KaoHe_JXDetail as b on a.ConText=b.Context left join View_TBDS_STAFFINFO as c on b.ST_ID=c.ST_ID inner join View_TBDS_KaoheDepartMonth as d on c.ST_DEPID=d.DepartId where d.state='2' and DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and Year='" + lastYear + "' and Month='" + lastMonth + "' and ST_DEPID='" + ddl_Depart.SelectedValue + "' and ST_PD in ('0','2')"; } else { sql = "insert into TBDS_KaoHe_JXDetail select distinct '" + creatContext + "','','0',d.Score,ST_GANGWEIXISHU,'0',DEP_POSITION,c.ST_ID,c.ST_NAME,ST_DEPID,c.DEP_NAME,DepMonth_Year,DepMonth_Month from dbo.TBDS_KaoHe_JXList as a left join dbo.TBDS_KaoHe_JXDetail as b on a.ConText=b.Context right join View_TBDS_STAFFINFO as c on b.ST_ID=c.ST_ID inner join View_TBDS_KaoheDepartMonth as d on c.ST_DEPID=d.DepartId where d.state='2' and DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and ST_DEPID='" + ddl_Depart.SelectedValue + "' and Year+Month in (select max(Year+Month) from dbo.TBDS_KaoHe_JXList as a left join dbo.TBDS_KaoHe_JXDetail as b on a.ConText=b.Context right join View_TBDS_STAFFINFO as c on b.ST_ID=c.ST_ID inner join View_TBDS_KaoheDepartMonth as d on c.ST_DEPID=d.DepartId where d.state='2' and DepMonth_Year='" + year + "' and DepMonth_Month='" + month + "' and ST_DEPID='" + ddl_Depart.SelectedValue + "' and ST_PD in ('0','2')) and ST_PD in ('0','2')"; } list.Add(sql); DBCallCommon.ExecuteTrans(list); ShowData(creatContext); CaculZongGZ(creatContext); }
private string GettxtPX_BH() { string pxbh = ""; string pxlx = ""; string bm = ""; string nf = ""; int lsh = 0; switch (asd.dt.Rows[0]["PX_FS"].ToString()) { case "n": pxlx = "I"; break; case "w": pxlx = "O"; break; default: break; } switch (asd.dt.Rows[0]["PX_BM"].ToString()) { case "综合办公室": bm = "G"; break; case "财务部": bm = "F"; break; case "市场部": bm = "M"; break; case "技术部": bm = "T"; break; case "质量部": bm = "Q"; break; case "设备安全管理部": bm = "ES"; break; case "设备安全管理部A": bm = "ES"; break; case "生产管理部": bm = "PM"; break; case "生产管理部A": bm = "PM"; break; case "生产管理部B": bm = "PM"; break; case "工程师办公室": bm = "E"; break; case "采购部": bm = "P"; break; default: break; } nf = DateTime.Now.ToString("yyyy"); //string sql = "select count(PX_ID) from ( 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 where PX_BM like '%" + asd.dt.Rows[0]["PX_BM"].ToString() + "%' and PX_FS='" + asd.dt.Rows[0]["PX_FS"].ToString() + "' and PX_BH like '%" + nf + "%'"; string sql = "select count(PX_ID) from ( 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 where PX_BH like '%" + nf + "%'"; DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); lsh = CommonFun.ComTryInt(dt.Rows[0][0].ToString()) + 1; if (lsh < 10) { pxbh = pxlx + "-" + bm + "-" + nf + "-" + lsh.ToString().PadLeft(2, '0'); } else { pxbh = pxlx + "-" + bm + "-" + nf + "-" + lsh.ToString(); } return(pxbh); }
//提交 protected void btnSave_OnClick(object sender, EventArgs e) { List <string> list = new List <string>(); string sql000 = ""; string sqlstaffinfo = ""; spbh = Request.QueryString["spid"].ToString().Trim(); string sqlsavedata = "select * from OM_JXADDSP where bh='" + spbh + "'"; DataTable dtsave = DBCallCommon.GetDTUsingSqlText(sqlsavedata); if (dtsave.Rows.Count > 0) { if (tb_yearmonth.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请选择年月!');", true); return; } if (lbstid.Text.Trim() == "" || txtname.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请填写人员信息!');", true); return; } if (txt_jxgzxs.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请填写绩效工资系数!');", true); return; } if (ddlType.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(this.Page, GetType(), "3", "alert('请选择类型!');", true); return; } if (dtsave.Rows[0]["creatstid"].ToString().Trim() == Session["UserID"].ToString().Trim() && dtsave.Rows[0]["totalstate"].ToString().Trim() == "0") { if (rblSHJS.SelectedValue.ToString().Trim() == "2") { if (txt_first.Text.Trim() == "" || firstid.Value.Trim() == "" || txt_second.Text.Trim() == "" || secondid.Value.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择审批人!');", true); return; } else { sql000 = "update OM_JXADDSP set creattime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',yearmonth='" + tb_yearmonth.Text.Trim() + "',things='" + txt_contents.Text.Trim() + "',jxaddstid='" + lbstid.Text.Trim() + "',jxaddstname='" + txtname.Text.Trim() + "',jxadddepartment='" + txtdepartment.Text.Trim() + "',jxgzxs='" + txt_jxgzxs.Text.Trim() + "',type='" + ddlType.SelectedValue.Trim() + "',totalstate='1',shrid1='" + firstid.Value.Trim() + "',shrname1='" + txt_first.Text.Trim() + "',shrid2='" + secondid.Value.Trim() + "',shrname2='" + txt_second.Text.Trim() + "',shjs='" + rblSHJS.SelectedValue.ToString().Trim() + "' where bh='" + spbh + "'"; list.Add(sql000); } } else if (rblSHJS.SelectedValue.ToString().Trim() == "1") { if (txt_first.Text.Trim() == "" || firstid.Value.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择审批人!');", true); return; } else { sql000 = "update OM_JXADDSP set creattime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',yearmonth='" + tb_yearmonth.Text.Trim() + "',things='" + txt_contents.Text.Trim() + "',jxaddstid='" + lbstid.Text.Trim() + "',jxaddstname='" + txtname.Text.Trim() + "',jxadddepartment='" + txtdepartment.Text.Trim() + "',jxgzxs='" + txt_jxgzxs.Text.Trim() + "',type='" + ddlType.SelectedValue.Trim() + "',totalstate='1',shrid1='" + firstid.Value.Trim() + "',shrname1='" + txt_first.Text.Trim() + "',shrid2='',shrname2='',shjs='" + rblSHJS.SelectedValue.ToString().Trim() + "' where bh='" + spbh + "'"; list.Add(sql000); } } //邮件提醒 string sprid = ""; string sptitle = ""; string spcontent = ""; sprid = firstid.Value.Trim(); sptitle = "人员绩效审批"; spcontent = txtname.Text.Trim() + "的" + lbtitle.Text.Trim() + "需要您审批,请登录查看!"; DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(sprid), new List <string>(), new List <string>(), sptitle, spcontent); } if (dtsave.Rows[0]["shrid1"].ToString().Trim() == Session["UserID"].ToString().Trim() && dtsave.Rows[0]["totalstate"].ToString().Trim() == "1") { if (rblfirst.SelectedValue.ToString().Trim() == "1") { if (rblSHJS.SelectedValue.ToString().Trim() == "1") { sql000 = "update OM_JXADDSP set totalstate='2',shstate1='1',shtime1='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',shnote1='" + opinion1.Text.Trim() + "' where bh='" + spbh + "'"; sqlstaffinfo = "update TBDS_STAFFINFO set ST_GANGWEIXISHU=" + CommonFun.ComTryDecimal(txt_jxgzxs.Text.Trim()) + " where ST_ID=" + CommonFun.ComTryInt(lbstid.Text.Trim()) + ""; list.Add(sql000); list.Add(sqlstaffinfo); } else if (rblSHJS.SelectedValue.ToString().Trim() == "2") { sql000 = "update OM_JXADDSP set shstate1='1',shtime1='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',shnote1='" + opinion1.Text.Trim() + "' where bh='" + spbh + "'"; list.Add(sql000); //邮件提醒 string sprid = ""; string sptitle = ""; string spcontent = ""; sprid = secondid.Value.Trim(); sptitle = "人员绩效审批"; spcontent = txtname.Text.Trim() + "的" + lbtitle.Text.Trim() + "需要您审批,请登录查看!"; DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(sprid), new List <string>(), new List <string>(), sptitle, spcontent); } } else if (rblfirst.SelectedValue.ToString().Trim() == "2") { sql000 = "update OM_JXADDSP set totalstate='3',shstate1='2',shtime1='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',shnote1='" + opinion1.Text.Trim() + "' where bh='" + spbh + "'"; list.Add(sql000); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择审核意见!');", true); return; } } if (dtsave.Rows[0]["shrid2"].ToString().Trim() == Session["UserID"].ToString().Trim() && dtsave.Rows[0]["totalstate"].ToString().Trim() == "1" && rblSHJS.SelectedValue.ToString().Trim() == "2") { if (rblsecond.SelectedValue.ToString().Trim() == "1") { sql000 = "update OM_JXADDSP set totalstate='2',shstate2='1',shtime2='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',shnote2='" + opinion2.Text.Trim() + "' where bh='" + spbh + "'"; sqlstaffinfo = "update TBDS_STAFFINFO set ST_GANGWEIXISHU=" + CommonFun.ComTryDecimal(txt_jxgzxs.Text.Trim()) + " where ST_ID=" + CommonFun.ComTryInt(lbstid.Text.Trim()) + ""; list.Add(sql000); list.Add(sqlstaffinfo); } else if (rblsecond.SelectedValue.ToString().Trim() == "2") { sql000 = "update OM_JXADDSP set totalstate='3',shstate2='2',shtime2='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',shnote2='" + opinion2.Text.Trim() + "' where bh='" + spbh + "'"; list.Add(sql000); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择审核意见!');", true); return; } } if (dtsave.Rows[0]["creatstid"].ToString().Trim() == Session["UserID"].ToString().Trim() && dtsave.Rows[0]["totalstate"].ToString().Trim() == "3") { sql000 = "update OM_JXADDSP set creattime='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Trim() + "',yearmonth='" + tb_yearmonth.Text.Trim() + "',things='" + txt_contents.Text.Trim() + "',jxaddstid='" + lbstid.Text.Trim() + "',jxaddstname='" + txtname.Text.Trim() + "',jxadddepartment='" + txtdepartment.Text.Trim() + "',jxgzxs='" + txt_jxgzxs.Text.Trim() + "',type='" + ddlType.SelectedValue.Trim() + "',totalstate='1',shstate1='0',shstate2='0' where bh='" + spbh + "'"; list.Add(sql000); //邮件提醒 string sprid = ""; string sptitle = ""; string spcontent = ""; sprid = firstid.Value.Trim(); sptitle = "人员绩效审批"; spcontent = txtname.Text.Trim() + "的" + lbtitle.Text.Trim() + "需要您审批,请登录查看!"; DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(sprid), new List <string>(), new List <string>(), sptitle, spcontent); } } DBCallCommon.ExecuteTrans(list); Response.Redirect("OM_JXADDSPdetail.aspx?spid=" + spbh); }
//绑定数据 private void binddata() { id_cwzb = Request.QueryString["id_cwzb"].ToString().Trim(); string sql = "select *,(yychengben+xsfeiyong+glfeiyong+cwfeiyong) as cbfeiyonghj,(yyshouru-yychengben-xsfeiyong-glfeiyong-cwfeiyong) as lrzonge from FM_CWZHIBIAO where id_cwzb=" + CommonFun.ComTryInt(id_cwzb) + ""; System.Data.DataTable dt = DBCallCommon.GetDTUsingSqlText(sql); if (dt.Rows.Count > 0) { dplYear.SelectedValue = dt.Rows[0]["cw_yearmonth"].ToString().Trim().Substring(0, 4); dplMoth.SelectedValue = dt.Rows[0]["cw_yearmonth"].ToString().Trim().Substring(5, 2); cw_zdrname.Text = dt.Rows[0]["cw_zdrname"].ToString().Trim(); cw_zdtime.Text = dt.Rows[0]["cw_zdtime"].ToString().Trim(); yychengben.Text = dt.Rows[0]["yychengben"].ToString().Trim(); xsfeiyong.Text = dt.Rows[0]["xsfeiyong"].ToString().Trim(); glfeiyong.Text = dt.Rows[0]["glfeiyong"].ToString().Trim(); cwfeiyong.Text = dt.Rows[0]["cwfeiyong"].ToString().Trim(); yychengbenys.Text = dt.Rows[0]["yychengbenys"].ToString().Trim(); xsfeiyongys.Text = dt.Rows[0]["xsfeiyongys"].ToString().Trim(); glfeiyongys.Text = dt.Rows[0]["glfeiyongys"].ToString().Trim(); cwfeiyongys.Text = dt.Rows[0]["cwfeiyongys"].ToString().Trim(); cbfeiyonghj.Text = dt.Rows[0]["cbfeiyonghj"].ToString().Trim(); cbfeiyonghjys.Text = dt.Rows[0]["cbfeiyonghjys"].ToString().Trim(); yyshouru.Text = dt.Rows[0]["yyshouru"].ToString().Trim(); yyshouruys.Text = dt.Rows[0]["yyshouruys"].ToString().Trim(); lrzonge.Text = dt.Rows[0]["lrzonge"].ToString().Trim(); lrzongeys.Text = dt.Rows[0]["lrzongeys"].ToString().Trim(); cw_note.Text = dt.Rows[0]["cw_note"].ToString().Trim(); } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (ddlYear.SelectedValue == "00" || ddlMonth.SelectedValue == "00") { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('请选择更新年月!');", true); return; } else { List <string> list = new List <string>(); string yearmonth = ddlYear.SelectedValue + "-" + ddlMonth.SelectedValue; string nextyear = ""; string nextmonth = ""; try { if (CommonFun.ComTryInt(ddlMonth.SelectedValue.ToString().Trim()) == 12) { nextyear = (CommonFun.ComTryInt(ddlYear.SelectedValue.ToString().Trim()) + 1).ToString().Trim(); nextmonth = "01"; } else { nextyear = ddlYear.SelectedValue.ToString().Trim(); nextmonth = (CommonFun.ComTryInt(ddlMonth.SelectedValue.ToString().Trim()) + 1).ToString("00").Trim(); } } catch { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('获取年月份出错!');", true); return; } if (CommonFun.ComTryInt(ddlYear.SelectedValue) >= 2015) { string sqlstaff = "select ST_ID,ST_NAME,ST_DEPID,ST_POSITION,ST_PD, b.DEP_NAME, ST_INTIME,ST_DATATIME from TBDS_STAFFINFO_record as a left join TBDS_DEPINFO as b on a.ST_POSITION=b.DEP_CODE WHERE ST_ID is not null and ST_NAME<>''and ST_NAME is not null and ST_DEPID is not null and ST_PD='0' and ST_DATATIME is not null and substring(ST_DATATIME,1,4)='" + nextyear + "' and substring(ST_DATATIME,6,2)='" + nextmonth + "'order by ST_DATATIME,ST_ID"; DataTable dtstaff = DBCallCommon.GetDTUsingSqlText(sqlstaff); if (dtstaff.Rows.Count > 0) { string sqldepnum = ""; DataTable dtdepnum; string sqlincnum = ""; DataTable dtincnum; string sqldecnum = ""; DataTable dtdecnum; string sqlvalid = ""; DataTable dtvalid; string sqlupdate = ""; string sqldep = "select distinct ST_DEPID,DEP_NAME from TBDS_STAFFINFO as a left join TBDS_DEPINFO as b on a.ST_DEPID=b.DEP_CODE where ST_DEPID is not null"; DataTable dtdep = DBCallCommon.GetDTUsingSqlText(sqldep); for (int i = 0; i < dtdep.Rows.Count; i++) { //部门人数 sqldepnum = "select count(*) from TBDS_STAFFINFO_record where substring(ST_DATATIME,1,4)='" + nextyear + "' and substring(ST_DATATIME,6,2)='" + nextmonth + "' and ST_ID is not null and ST_NAME<>''and ST_NAME is not null and ST_DEPID is not null and ST_PD='0' and ST_DEPID='" + dtdep.Rows[i][0].ToString() + "'"; dtdepnum = DBCallCommon.GetDTUsingSqlText(sqldepnum); //增减人员信息 sqlincnum = "select ST_ID,ST_NAME,ST_DEPID,ST_DEPID1,ST_POSITION,ST_PD, b.DEP_NAME, ST_INTIME,ST_DATATIME from TBDS_STAFFINFO_record as a left join TBDS_DEPINFO as b on a.ST_POSITION=b.DEP_CODE WHERE ST_ID is not null and ST_NAME<>''and ST_NAME is not null and ST_DEPID is not null and ST_PD='0' and ST_DATATIME is not null and substring(ST_DATATIME,1,4)='" + nextyear + "' and substring(ST_DATATIME,6,2)='" + nextmonth + "'and ST_DEPID='" + dtdep.Rows[i][0].ToString() + "'and ST_ID not in (select ST_ID from TBDS_STAFFINFO_record as a left join TBDS_DEPINFO as b on a.ST_POSITION=b.DEP_CODE WHERE ST_ID is not null and ST_NAME<>''and ST_NAME is not null and ST_DEPID is not null and ST_PD='0' and ST_DATATIME is not null and substring(ST_DATATIME,1,4)='" + ddlYear.SelectedValue + "' and substring(ST_DATATIME,6,2)='" + ddlMonth.SelectedValue + "'and ST_DEPID='" + dtdep.Rows[i][0].ToString() + "') order by ST_DATATIME,ST_ID"; dtincnum = DBCallCommon.GetDTUsingSqlText(sqlincnum); sqldecnum = "select ST_ID,ST_NAME,ST_DEPID,ST_DEPID1,ST_POSITION,ST_PD, b.DEP_NAME, ST_INTIME,ST_DATATIME from TBDS_STAFFINFO_record as a left join TBDS_DEPINFO as b on a.ST_POSITION=b.DEP_CODE WHERE ST_ID is not null and ST_NAME<>''and ST_NAME is not null and ST_DEPID is not null and ST_PD='0' and ST_DATATIME is not null and substring(ST_DATATIME,1,4)='" + ddlYear.SelectedValue + "' and substring(ST_DATATIME,6,2)='" + ddlMonth.SelectedValue + "'and ST_DEPID='" + dtdep.Rows[i][0].ToString() + "'and ST_ID not in (select ST_ID from TBDS_STAFFINFO_record as a left join TBDS_DEPINFO as b on a.ST_POSITION=b.DEP_CODE WHERE ST_ID is not null and ST_NAME<>''and ST_NAME is not null and ST_DEPID is not null and ST_PD='0' and ST_DATATIME is not null and substring(ST_DATATIME,1,4)='" + nextyear + "' and substring(ST_DATATIME,6,2)='" + nextmonth + "'and ST_DEPID='" + dtdep.Rows[i][0].ToString() + "') order by ST_DATATIME,ST_ID"; dtdecnum = DBCallCommon.GetDTUsingSqlText(sqldecnum); string incperson = ""; string decperson = ""; for (int m = 0; m < dtincnum.Rows.Count; m++) { if (dtincnum.Rows[m]["ST_DEPID1"].ToString() != null && dtincnum.Rows[m]["ST_DEPID1"].ToString() != "") { incperson += dtincnum.Rows[m]["ST_NAME"].ToString() + "(" + dtincnum.Rows[m]["ST_DEPID1"].ToString() + ":" + dtincnum.Rows[m]["DEP_NAME"].ToString() + ")/"; } else { incperson += dtincnum.Rows[m]["ST_NAME"].ToString() + "(" + dtincnum.Rows[m]["DEP_NAME"].ToString() + ")/"; } } for (int n = 0; n < dtdecnum.Rows.Count; n++) { if (dtdecnum.Rows[n]["ST_DEPID1"].ToString() != null && dtdecnum.Rows[n]["ST_DEPID1"].ToString() != "") { decperson += dtdecnum.Rows[n]["ST_NAME"].ToString() + "(" + dtdecnum.Rows[n]["ST_DEPID1"].ToString() + ":" + dtdecnum.Rows[n]["DEP_NAME"].ToString() + ")/"; } else { decperson += dtdecnum.Rows[n]["ST_NAME"].ToString() + "(" + dtdecnum.Rows[n]["DEP_NAME"].ToString() + ")/"; } } if (dtincnum.Rows.Count > 0) { incperson = incperson.Substring(0, incperson.LastIndexOf('/')); } if (dtdecnum.Rows.Count > 0) { decperson = decperson.Substring(0, decperson.LastIndexOf('/')); } sqlvalid = "select * from OM_StaffChange where SC_YearMonth='" + yearmonth + "'"; dtvalid = DBCallCommon.GetDTUsingSqlText(sqlvalid); if (dtvalid.Rows.Count > 0)//更新 { sqlupdate = "update OM_StaffChange set SC_DepNum='" + dtdepnum.Rows[0][0].ToString() + "',SC_STDepID='" + dtdep.Rows[i][0].ToString() + "', SC_STDep='" + dtdep.Rows[i][1].ToString() + "', SC_YearMonth='" + yearmonth + "', SC_IncNum='" + dtincnum.Rows.Count.ToString() + "', SC_DecNum='" + dtdecnum.Rows.Count.ToString() + "', SC_IncPersonInfo='" + incperson + "', SC_DecPersonInfo='" + decperson + "'where SC_STDepID='" + dtdep.Rows[i][0].ToString() + "'and SC_YearMonth='" + yearmonth + "'"; list.Add(sqlupdate); } else//新增 { sqlupdate = "insert into OM_StaffChange ( SC_DepNum,SC_STDepID,SC_STDep,SC_YearMonth,SC_IncNum,SC_DecNum,SC_IncPersonInfo,SC_DecPersonInfo)values('" + dtdepnum.Rows[0][0].ToString() + "','" + dtdep.Rows[i][0].ToString() + "', '" + dtdep.Rows[i][1].ToString() + "', '" + yearmonth + "', '" + dtincnum.Rows.Count.ToString() + "', '" + dtdecnum.Rows.Count.ToString() + "', '" + incperson + "', '" + decperson + "')"; list.Add(sqlupdate); } } try { DBCallCommon.ExecuteTrans(list); UCPaging1.CurrentPage = 1; databind(); } catch { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('更新失败,请联系管理员!');", true); return; } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('" + ddlYear.SelectedValue + "年" + ddlMonth.SelectedValue + "月没有相关数据!');", true); return; } } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('" + ddlYear.SelectedValue + "年没有相关数据!');", true); return; } } }