protected void imgbtnDF_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imgbtn      = (ImageButton)sender;
            GridViewRow gvr         = (GridViewRow)imgbtn.Parent.Parent;
            GridView    gv          = (GridView)TabContainer1.FindControl("TabPanel1").FindControl("GridView1");
            string      sqlStr      = "select fileload,fileName,showName from " + ((ImageButton)sender).ID + " where fileID='" + gv.DataKeys[gvr.RowIndex].Value.ToString() + "'";
            DataSet     ds          = DBCallCommon.FillDataSet(sqlStr);
            string      strFilePath = ds.Tables[0].Rows[0]["fileload"].ToString() + @"\" + ds.Tables[0].Rows[0]["fileName"].ToString();

            if (File.Exists(strFilePath))
            {
                string             showName = ds.Tables[0].Rows[0]["showName"].ToString();
                System.IO.FileInfo file     = new System.IO.FileInfo(strFilePath);
                Response.Clear();
                Response.ClearHeaders();
                Response.Buffer      = true;
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(showName));
                Response.AppendHeader("Content-Length", file.Length.ToString());
                Response.WriteFile(file.FullName);
                Response.Flush();
                Response.End();
            }
            else
            {
                filesError.Visible = true;
                filesError.Text    = "文件已被删除,请通知相关人员上传文件!";
            }
        }
        private void Control_Enable()
        {
            string    sql = "select * from TBCM_PLAN where ID='" + id + "'";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                int     n  = int.Parse(dr["CM_PSJB"].ToString());
                for (int i = 0; i < n; i++)
                {
                    Panel pal = new Panel();
                    pal = (Panel)TabContainer1.FindControl("Pan_ShenHe").FindControl("Panel" + i.ToString());
                    TextBox tbyj = (TextBox)TabContainer1.FindControl("Pan_ShenHe").FindControl("txt_shyj" + i.ToString());

                    Label       lb = (Label)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shr" + i.ToString());
                    HiddenField hd = (HiddenField)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shrid" + i.ToString());
                    if (UserID.Value == hd.Value && tbyj.Text == "")
                    {
                        pal.Enabled      = true;
                        tbyj.BorderColor = System.Drawing.Color.Orange;
                        tbyj.Focus();
                        LbtnYes.Visible = true;
                        LbtnNO.Visible  = true;
                        if (action == "look")
                        {
                            pal.Enabled = false;
                        }
                        break;
                    }
                    else
                    {
                        pal.Enabled = false;
                    }
                }
            }
        }
Exemple #3
0
        private void ExeSQL(int j)
        {
            #region 评审代码

            List <string> strb_sql = new List <string>();
            string        psyj     = "";
            string        txt_yj   = "";                                  //意见文本框中的文字
            string        riqi     = DateTime.Now.ToString("yyyy-MM-dd"); //评审时间
            string        username = Session["UserName"].ToString();

            //评审人是部门负责人
            string    sqlText = "select *,b.DEP_NAME from TBDS_PSVIEW as a left join TBDS_DEPINFO as b on a.ST_DEP=b.DEP_CODE where ST_ID='" + id + "'and ST_PIDTYPE ='1' and  ST_DEP!='01'";
            DataTable dt      = DBCallCommon.GetDTUsingSqlText(sqlText);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Label    lb      = (Label)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shr" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1])
                {
                    TextBox txt_shyj = (TextBox)TabContainer1.FindControl("Pan_ShenHe").FindControl("txt_shyj" + i.ToString());
                    txt_yj = txt_shyj.Text;
                }
            }

            //评审人是公司领导
            sqlText = "select *,b.DEP_NAME from TBDS_PSVIEW as a left join TBDS_DEPINFO as b on a.ST_DEP=b.DEP_CODE where ST_ID='" + id + "'and ST_PIDTYPE ='1' and  ST_DEP='01'";
            DataTable dt_gsld = DBCallCommon.GetDTUsingSqlText(sqlText);
            for (int i = 0; i < dt_gsld.Rows.Count; i++)
            {
                Label    lb      = (Label)TabContainer1.FindControl("Pan_Leader").FindControl("lb_shr_ld" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1])
                {
                    TextBox txt_shyj = (TextBox)TabContainer1.FindControl("Pan_Leader").FindControl("txt_shyj_ld" + i.ToString());
                    txt_yj = txt_shyj.Text;
                }
            }
            if (j == 3)
            {
                if (txt_yj == "")
                {
                    if (Session["UserDeptID"].ToString() != "01")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('驳回意见不能为空!');", true); return;
                    }
                    psyj = txt_yj;
                }
                else
                {
                    psyj = txt_yj;
                }
            }
            else
            {
                if (txt_yj == "")
                {
                    psyj = "同意";
                }
                else
                {
                    psyj = txt_yj;
                }
            }

            #endregion

            string sql = "update TBDS_PSVIEW set ST_PSYJ='" + j.ToString() + "',ST_NOTE='" + psyj + "' ,ST_SHSJ='" + riqi + "' where ST_ID='" + id + "' and ST_PID='" + Session["UserID"].ToString() + "'";
            strb_sql.Add(sql);

            if (j == 2)
            {
                //部门评审完之后,提醒领导需要审批
                sql = "select * from TBDS_PSVIEW where ST_DEP!='01' and ST_PSYJ='1'";
                int jud = DBCallCommon.GetDTUsingSqlText(sql).Rows.Count;
                sql = "select * from TBDS_PSVIEW where ST_DEP='01' and ST_PSYJ!='1'";//领导审批之后不需要重复发送邮件
                DataTable leader = DBCallCommon.GetDTUsingSqlText(sql);
                int       jud1   = leader.Rows.Count;
                string    item   = string.Empty;
                if (jud != 0 && jud1 == 0)
                {
                    switch (type)
                    {
                    case "0":
                        item = "人员转正";
                        break;

                    case "1":
                        item = "合同签订";
                        break;

                    case "2":
                        item = "人员流动";
                        break;

                    case "3":
                        item = "人员年假";
                        break;

                    default:
                        break;
                    }
                    for (int i = 0; i < jud1; i++)
                    {
                        DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(leader.Rows[i]["ST_PID"].ToString()), new List <string>(), new List <string>(), "部门评审完毕", string.Format("您有{0}审批!", item));
                    }
                }
            }

            //修改评审状态 评审完成2,已驳回3,
            //根据类型来修改相应的表
            if (j == 3) //不同意
            {
                sql = "update TBDS_PSDETAIL set ST_PSZT='3' where ST_ID='" + id + "'";
                strb_sql.Add(sql);
                //发送邮件通知——审批驳回
                //SendMail("no");
            }
            else //同意 如果除此人以外其他人都同意了,则审批状态改为审批完成
            {
                sql = "select * from TBDS_PSVIEW where ST_ID='" + id + "' and ST_PID!='" + Session["UserID"].ToString() + "' and ST_PSYJ!='2'";
                DataTable dt_check = DBCallCommon.GetDTUsingSqlText(sql);
                if (dt_check.Rows.Count == 0)
                {
                    sql = "update TBDS_PSDETAIL set ST_PSZT='2' where ST_ID='" + id + "'";
                    strb_sql.Add(sql);
                    if (type == "0")
                    {
                        sql = "update TBDS_STAFFINFO ST_ZHUANZ='1' where ST_ID='" + lb_Id.Text + "'";
                        strb_sql.Add(sql);
                    }
                    else if (type == "1")
                    {
                        sql = "update TBDS_STAFFINFO set ST_CONTRSTART='" + lb_Start.Text + "',ST_CONTREND='" + lb_End.Text + "' where ST_ID='" + lb_Id.Text + "'";
                        strb_sql.Add(sql);
                        sql = string.Format("insert into TBDS_HETONG values('{0}','{1}','{2}','{3}')", lb_Id.Text, lb_Start.Text, lb_End.Text, DateTime.Now.ToString());
                        strb_sql.Add(sql);
                    }
                    else if (type == "2")
                    {
                        sql = "update TBDS_STAFFINFO set ST_DEPID='" + lb_DepId.Text + "'";
                    }
                    //发送邮件通知——审批通过
                    //SendMail("yes");
                }
            }
            DBCallCommon.ExecuteTrans(strb_sql);
        }
Exemple #4
0
        private void Control_Enable()
        {
            string username = Session["UserName"].ToString();
            //部门负责人
            string    sqlbmfzr = "select a.*,b.DEP_NAME from TBDS_PSVIEW as a left join TBDS_DEPINFO as b on a.ST_DEP=b.DEP_CODE where a.ST_ID='" + id + "'and ST_PIDTYPE ='1' and  ST_DEP!='01'";
            DataTable dt_bmfzr = DBCallCommon.GetDTUsingSqlText(sqlbmfzr);

            for (int i = 0; i < dt_bmfzr.Rows.Count; i++)
            {
                Panel pal = new Panel();
                pal = (Panel)TabContainer1.FindControl("Pan_ShenHe").FindControl("Panel" + i.ToString());
                TextBox tbyj = (TextBox)TabContainer1.FindControl("Pan_ShenHe").FindControl("txt_shyj" + i.ToString());

                Label    lb      = (Label)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shr" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1])
                {
                    pal.Enabled      = true;
                    tbyj.BorderColor = System.Drawing.Color.Orange;
                    tbyj.Focus();
                    LbtnYes.Visible = true;
                    LbtnNO.Visible  = true;
                }
                else
                {
                    pal.Enabled = false;
                }
            }

            //公司领导
            string    sqlgsld = "select a.*,b.DEP_NAME from TBDS_PSVIEW as a left join TBDS_DEPINFO as b on a.ST_DEP=b.DEP_CODE where a.ST_ID='" + id + "'and ST_PIDTYPE ='1' and  ST_DEP='01'";
            DataTable dt_gsld = DBCallCommon.GetDTUsingSqlText(sqlgsld);

            for (int i = 0; i < dt_gsld.Rows.Count; i++)
            {
                Panel pal = new Panel();
                pal = (Panel)TabContainer1.FindControl("Pan_Leader").FindControl("Panel" + i.ToString());
                TextBox tbyj = (TextBox)TabContainer1.FindControl("Pan_Leader").FindControl("txt_shyj_ld" + i.ToString());

                Label    lb      = (Label)TabContainer1.FindControl("Pan_Leader").FindControl("lb_shr_ld" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1])
                {
                    //对于公司领导,审计通过后才能审核
                    string    check_sjyj    = "select distinct ST_PSYJ FROM TBDS_PSVIEW WHERE ST_ID='" + id + "'and ST_DEP<>'01' AND ST_PSYJ='0'";
                    DataTable dt_check_sjyj = DBCallCommon.GetDTUsingSqlText(check_sjyj);
                    if ((Session["UserDeptID"].ToString() == "01" && dt_check_sjyj.Rows.Count == 0) || Session["UserDeptID"].ToString() != "01")
                    {
                        pal.Enabled      = true;
                        tbyj.BorderColor = System.Drawing.Color.Orange;
                        tbyj.Focus();
                        LbtnYes.Visible = true;
                        LbtnNO.Visible  = true;
                    }
                    else
                    {
                        pal.Enabled = false;
                    }
                }
                else
                {
                    pal.Enabled = false;
                }
            }
        }
Exemple #5
0
        private void ExcuteSql(int j)
        {
            List <string> str_sql = new List <string>();
            string        sql     = "";
            string        psyj    = "";
            string        txt_yj  = "";                                  //意见文本框中的文字
            string        riqi    = DateTime.Now.ToString("yyyy-MM-dd"); //评审时间

            //评审人意见
            sql = "select * from TBCM_CHANLIST where CH_ID='" + chId + "'";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);
            int       psr = 0;
            int       n   = 0;

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                n = int.Parse(dr["CM_PSJB"].ToString());
                for (int i = 0; i < n; i++)
                {
                    Label       lb       = (Label)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shr" + i);
                    TextBox     txt_shyj = (TextBox)TabContainer1.FindControl("Pan_ShenHe").FindControl("txt_shyj" + i);
                    HiddenField hd       = (HiddenField)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shrid" + i.ToString());
                    if (UserID.Value == hd.Value)
                    {
                        txt_yj = txt_shyj.Text;
                        psr    = i + 1;
                    }
                }

                //修改评审状态 评审完成2,已驳回3,
                //根据类型来修改相应的表
                if (j == 2)
                {
                    if (txt_yj == "")
                    {
                        psyj = "同意";
                    }
                    else
                    {
                        psyj = txt_yj;
                    }
                    //评审完之后,邮件提示下一个人有计划单需要审批
                    if (psr < 3 && psr < n)
                    {
                        DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_PS" + (psr + 1)].ToString()), new List <string>(), new List <string>(), "经营计划单评审", "您有经营计划单需要评审!");
                    }

                    if (psr == n && dt.Rows[0]["CM_STATE"].ToString() == "1")
                    {
                        sql = "update TBCM_CHANLIST set CM_STATE='2' where CH_ID='" + chId + "'";
                        str_sql.Add(sql);

                        //计划单增补
                        List <string> tsaId             = new List <string>();
                        Dictionary <string, string> dic = new Dictionary <string, string>();
                        string    strsql = "select * from TBCM_CHANGE where CH_ID='" + chId + "'";
                        DataTable newId  = DBCallCommon.GetDTUsingSqlText(strsql);
                        foreach (DataRow drow in newId.Rows)
                        {
                            tsaId.Add(drow["TSA_ID"].ToString());
                            sql = string.Format("insert into TBCM_BASIC(ID,TSA_ID,TSA_ENGNAME,TSA_MAP,TSA_NUMBER,TSA_UNIT,TSA_MATERIAL,TSA_IDNOTE,TSA_TYPE) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", id, drow["TSA_ID"].ToString(), drow["TSA_ENGNAME"].ToString(), drow["TSA_MAP"].ToString(), drow["TSA_NUMBER"].ToString(), drow["TSA_UNIT"].ToString(), drow["TSA_MATERIAL"].ToString(), drow["TSA_IDNOTE"].ToString(), drow["TSA_TYPE"].ToString());
                            str_sql.Add(sql);
                        }
                        //附件添加
                        strsql = "select * from tb_files where BC_CONTEXT='" + chId + "'";
                        DataTable tbfile = DBCallCommon.GetDTUsingSqlText(strsql);
                        strsql = "select * from TBCM_PLAN where ID='" + id + "'";
                        DataTable context = DBCallCommon.GetDTUsingSqlText(strsql);
                        for (int i = 0; i < tbfile.Rows.Count; i++)
                        {
                            if (context.Rows.Count > 0)
                            {
                                DataRow tbrow = tbfile.Rows[i];
                                sql = string.Format("insert into tb_files values('{0}','{1}','{2}','{3}','{4}')", context.Rows[0]["CM_CONTEXT"].ToString(), tbrow["fileload"].ToString(), tbrow["fileUpDate"].ToString(), tbrow["fileName"].ToString(), tbrow["ShowName"].ToString());
                                str_sql.Add(sql);
                            }
                        }

                        tsaId.Distinct().ToList();
                        foreach (string item in tsaId)
                        {
                            strsql = "select * from TBCM_BASIC where TSA_ID='" + item + "'";
                            DataTable dt1 = DBCallCommon.GetDTUsingSqlText(strsql);
                            strsql = "select * from TBCM_CHANGE where CH_ID='" + chId + "' and TSA_ID='" + item + "'";
                            DataTable dt2     = DBCallCommon.GetDTUsingSqlText(strsql);
                            string    engName = "";
                            if (dt1.Rows.Count > 0)
                            {
                                for (int i = 0; i < dt1.Rows.Count; i++)
                                {
                                    engName += "," + dt1.Rows[i]["TSA_ENGNAME"].ToString();
                                }
                                for (int i = 0; i < dt2.Rows.Count; i++)
                                {
                                    engName += "," + dt2.Rows[i]["TSA_ENGNAME"].ToString();
                                }
                                engName = engName.Substring(1);
                            }
                        }
                        //计划单增补审核通过插入销售合同
                        string tsa_id  = "";
                        string sqltext = "";
                        string jhdtype = "";

                        foreach (GridViewRow gr in GridView1.Rows)
                        {
                            string TSA_ID = ((System.Web.UI.WebControls.Label)gr.FindControl("TSA_ID")).Text.ToString();
                            if (TSA_ID == "" || TSA_ID == null)
                            {
                                TSA_ID = tsa_id;
                            }
                            else
                            {
                                tsa_id = TSA_ID;
                            }
                            string    CM_ENGNAME  = ((System.Web.UI.WebControls.Label)gr.FindControl("TSA_ENGNAME")).Text.ToString();
                            string    CM_MAP      = ((System.Web.UI.WebControls.Label)gr.FindControl("TSA_MAP")).Text.ToString();
                            string    CM_NUMBER   = ((System.Web.UI.WebControls.Label)gr.FindControl("TSA_NUMBER")).Text.ToString();
                            string    CM_UNIT     = ((System.Web.UI.WebControls.Label)gr.FindControl("TSA_UNIT")).Text.ToString();
                            string    CM_MATERIAL = ((System.Web.UI.WebControls.Label)gr.FindControl("TSA_MATERIAL")).Text.ToString();
                            string    sqlstid     = "select TSA_ID from TBPM_DETAIL where CM_CONTR='" + CM_CONTR.Text.Trim() + "'and TSA_ID='" + tsa_id.Trim() + "' and CM_JHDTYPE='0'";
                            DataTable stiddata    = DBCallCommon.GetDTUsingSqlText(sqlstid);
                            if (stiddata.Rows.Count > 0)
                            {
                                jhdtype = "1";
                            }
                            else
                            {
                                jhdtype = "3";
                            }

                            sqltext = "insert into TBPM_DETAIL(CM_CONTR,TSA_ID,CM_PROJ,CM_YZHTH,CM_ENGNAME,CM_MATERIAL,CM_MAP,CM_NUMBER,CM_UNIT,CM_JHDTYPE) values('" + CM_CONTR.Text.Trim() + "','" + tsa_id.Trim() + "','" + CM_PROJ.Text.Trim() + "','" + CM_DFCONTR.Text.Trim() + "','" + CM_ENGNAME.Trim() + "','" + CM_MATERIAL.Trim() + "','" + CM_MAP.Trim() + "','" + CM_NUMBER.Trim() + "','" + CM_UNIT.Trim() + "','" + jhdtype + "')";
                            str_sql.Add(sqltext);
                        }

                        //2017.1.5修改,添加合同号和项目名称
                        string cs = "select CM_PID,CM_CONTR,CM_PROJ from TBCM_PSVIEW left join TBCM_CHANGE on TBCM_PSVIEW.CM_ID=TBCM_CHANGE.CH_ID left join TBCM_PLAN on TBCM_CHANGE.ID=TBCM_PLAN.ID where TBCM_PSVIEW.CM_ID='" + chId + "'  and CM_PIDTYPE<>''and CM_PIDTYPE is not null";
                        //string cs = "select CM_PID from TBCM_PSVIEW where CM_ID='" + chId + "' and CM_PIDTYPE<>''and CM_PIDTYPE is not null";
                        DataTable     cs_dt   = DBCallCommon.GetDTUsingSqlText(cs);
                        List <string> cs_list = new List <string>();
                        for (int i = 0; i < cs_dt.Rows.Count; i++)
                        {
                            cs_list.Add(DBCallCommon.GetEmailAddressByUserID(cs_dt.Rows[i][0].ToString()));
                        }
                        if (!cs_list.Contains(DBCallCommon.GetEmailAddressByUserID("202")))
                        {
                            cs_list.Add(DBCallCommon.GetEmailAddressByUserID("202"));
                        }

                        if (cs_list.Count != 0)
                        {
                            cs_list = cs_list.Distinct().ToList();
                            for (int k = 0; k < cs_list.Count; k++)
                            {
                                string fa_all_mail = cs_list[k];
                                //2017.1.5修改,添加合同号和项目名称
                                DBCallCommon.SendEmail(fa_all_mail, new List <string>(), new List <string>(), "经营计划单增补", "您有合同号为" + cs_dt.Rows[0]["CM_CONTR"].ToString() + ",项目名称为" + cs_dt.Rows[0]["CM_PROJ"].ToString() + "的经营计划单增补需要查看!");
                                //DBCallCommon.SendEmail(fa_all_mail, new List<string>(), new List<string>(), "经营计划单增补", "您有经营计划单增补需要查看!");
                            }
                        }
                        // DBCallCommon.SendEmail("", cs_list, new List<string>(), "经营计划单增补", "您有经营计划单增补需要查看!");
                    }
                }
                else  //不同意
                {
                    if (txt_yj == "")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('驳回意见不能为空!');", true); return;
                    }
                    else
                    {
                        psyj = txt_yj;
                    }
                    sql = "update TBCM_CHANLIST set CM_STATE='3' where CH_ID='" + chId + "'";
                    str_sql.Add(sql);
                    DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_MANCLERK"].ToString()), new List <string>(), new List <string>(), "经营计划单被驳回", "您提交的经营计划单被驳回!请修改后再次提交");
                }
                sql = string.Format("update TBCM_CHANLIST set CM_PSYJ{0}='{1}',CM_PSSJ{0}='{2}',CM_NOTE{0}='{3}' where CH_ID='{4}'", psr, j, riqi, psyj, chId);
                str_sql.Add(sql);
                DBCallCommon.ExecuteTrans(str_sql);
                Response.Redirect("CM_ZengBuPs.aspx");
            }
        }
        private void ExcuteSql(int j)
        {
            List <string> str_sql = new List <string>();
            string        sql     = "";
            string        psyj    = "";
            string        txt_yj  = "";                                  //意见文本框中的文字
            string        riqi    = DateTime.Now.ToString("yyyy-MM-dd"); //评审时间

            //评审人意见
            sql = "select * from TBCM_CHANLIST where CH_ID='" + chId + "'";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);
            int       psr = 0;
            int       n   = 0;

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                n = int.Parse(dr["CM_PSJB"].ToString());
                for (int i = 0; i < n; i++)
                {
                    Label       lb       = (Label)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shr" + i);
                    TextBox     txt_shyj = (TextBox)TabContainer1.FindControl("Pan_ShenHe").FindControl("txt_shyj" + i);
                    HiddenField hd       = (HiddenField)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shrid" + i.ToString());
                    if (UserID.Value == hd.Value)
                    {
                        txt_yj = txt_shyj.Text;
                        psr    = i + 1;
                    }
                }

                //修改评审状态 评审完成2,已驳回3,
                //根据类型来修改相应的表
                if (j == 2)
                {
                    if (txt_yj == "")
                    {
                        psyj = "同意";
                    }
                    else
                    {
                        psyj = txt_yj;
                    }
                    //评审完之后,邮件提示下一个人有计划单需要审批
                    if (psr < 3 && psr < n)
                    {
                        DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_PS" + (psr + 1)].ToString()), new List <string>(), new List <string>(), "经营计划单评审", "您有经营计划单需要评审!");
                    }

                    if (psr == n && dt.Rows[0]["CM_STATE"].ToString() == "1")
                    {
                        sql = "update TBCM_CHANLIST set CM_STATE='2' where CH_ID='" + chId + "'";
                        str_sql.Add(sql);

                        //制作内容变更
                        string sql00 = "";
                        sql = "select * from TBCM_CHANGE where CH_ID='" + chId + "' and CM_CHANITEM='1'";
                        DataTable dtchange = DBCallCommon.GetDTUsingSqlText(sql);
                        for (int i = 0; i < dtchange.Rows.Count; i++)
                        {
                            DataRow drch = dtchange.Rows[i];
                            sql = string.Format("update TBCM_BASIC set TSA_ENGNAME='{0}',TSA_MAP='{1}',TSA_NUMBER='{2}',TSA_UNIT='{3}',TSA_MATERIAL='{4}',TSA_TYPE='{5}',TSA_IDNOTE='{6}' where ID='{7}' and CM_ID='{8}'", drch["TSA_ENGNAME"].ToString(), drch["TSA_MAP"].ToString(), drch["TSA_NUMBER"].ToString(), drch["TSA_UNIT"].ToString(), drch["TSA_MATERIAL"].ToString(), drch["TSA_TYPE"].ToString(), drch["TSA_IDNOTE"].ToString(), drch["ID"].ToString(), drch["CM_ID"].ToString());
                            str_sql.Add(sql);

                            //计划单变更通过更新销售合同明细
                            sql00 = "select * from TBCM_CHANGE where CH_ID='" + chId + "' and CM_CHANITEM='0'";
                            DataTable dtchange00 = DBCallCommon.GetDTUsingSqlText(sql00);
                            DataRow   drch00     = dtchange00.Rows[i];
                            sql = string.Format("update TBPM_DETAIL set CM_ENGNAME='{0}',CM_MAP='{1}',CM_NUMBER='{2}',CM_UNIT='{3}',CM_MATERIAL='{4}' where  CM_CONTR='{5}' and TSA_ID='{6}' and CM_PROJ='{7}'and CM_ENGNAME='{8}'and CM_MAP='{9}'and CM_MATERIAL='{10}'and CM_NUMBER='{11}'and CM_UNIT='{12}'", drch["TSA_ENGNAME"].ToString(), drch["TSA_MAP"].ToString(), drch["TSA_NUMBER"].ToString(), drch["TSA_UNIT"].ToString(), drch["TSA_MATERIAL"].ToString(), CM_CONTR.Text.ToString(), drch00["TSA_ID"].ToString(), CM_PROJ.Text.ToString(), drch00["TSA_ENGNAME"].ToString(), drch00["TSA_MAP"].ToString(), drch00["TSA_MATERIAL"].ToString(), drch00["TSA_NUMBER"].ToString(), drch00["TSA_UNIT"].ToString());
                            str_sql.Add(sql);

                            DataTable dt2 = DBCallCommon.GetDTUsingSqlText("select * from TBCM_CHANGE where CH_ID='" + chId + "' and CM_CHANITEM='0' and CM_ID='" + drch["CM_ID"].ToString() + "'");
                            if (dt2.Rows.Count > 0)
                            {
                                if (dt2.Rows[0]["TSA_TYPE"].ToString() != drch["TSA_TYPE"].ToString())
                                {
                                    sql = string.Format("update TBCM_BASIC set TSA_TYPE='{0}' where ID='{1}' and TSA_ID='{2}'", drch["TSA_TYPE"].ToString(), drch["ID"].ToString(), drch["TSA_ID"].ToString());
                                    str_sql.Add(sql);
                                }
                            }
                        }

                        //其他变更
                        Dictionary <string, string> dic = new Dictionary <string, string>()
                        {
                            { "交货日期", "CM_FHDATE" }, { "质量标准", "CM_LEVEL" }, { "质量校验与验收", "CM_TEST" }, { "交货地点及运输方式", "CM_JHADDRESS" }, { "包装要求", "CM_BZ" }, { "交货要求", "CM_JH" }, { "油漆要求", "CM_YQ" }, { "买方责任人", "CM_DUTY" }, { "备注", "CM_NOTE" }, { "对方合同号", "CM_DFCONTR" }
                        };
                        sql      = "select a.*,b.ID from TBCM_ChangePart as a left join TBCM_CHANLIST as b on a.CH_ID=b.CH_ID where a.CH_ID='" + chId + "' and CM_CHANITEM='1'";
                        dtchange = DBCallCommon.GetDTUsingSqlText(sql);
                        for (int i = 0; i < dtchange.Rows.Count; i++)
                        {
                            DataRow drch = dtchange.Rows[i];
                            sql = string.Format("update TBCM_PLAN set {0}='{1}' where ID='{2}'", dic[drch["CM_BGXM"].ToString()], drch["CM_CONTENT"].ToString(), drch["ID"].ToString());
                            str_sql.Add(sql);
                        }
                        //2017.1.5修改,添加合同号和项目名称
                        string cs = "select CM_PID,CM_CONTR,CM_PROJ from TBCM_PSVIEW left join TBCM_CHANGE on TBCM_PSVIEW.CM_ID=TBCM_CHANGE.CH_ID left join TBCM_PLAN on TBCM_CHANGE.ID=TBCM_PLAN.ID where TBCM_PSVIEW.CM_ID='" + chId + "' and CM_PIDTYPE='1'";
                        //string cs = "select CM_PID from TBCM_PSVIEW where CM_ID='" + chId + "' and CM_PIDTYPE='1'";

                        DataTable     cs_dt   = DBCallCommon.GetDTUsingSqlText(cs);
                        List <string> cs_list = new List <string>();
                        for (int i = 0; i < cs_dt.Rows.Count; i++)
                        {
                            cs_list.Add(DBCallCommon.GetEmailAddressByUserID(cs_dt.Rows[i][0].ToString()));
                        }
                        //2017.1.13修改,直接添加王艳辉
                        if (!cs_list.Contains(DBCallCommon.GetEmailAddressByUserID("202")))
                        {
                            cs_list.Add(DBCallCommon.GetEmailAddressByUserID("202"));
                        }
                        //2017.1.5修改,添加合同号和项目名称
                        if (cs_list.Count != 0)
                        {
                            cs_list = cs_list.Distinct().ToList();
                            for (int k = 0; k < cs_list.Count; k++)
                            {
                                string fa_all_mail = cs_list[k];
                                DBCallCommon.SendEmail(fa_all_mail, new List <string>(), new List <string>(), "经营计划单变更", "您有合同号为" + cs_dt.Rows[0]["CM_CONTR"].ToString() + ",项目名称为" + cs_dt.Rows[0]["CM_PROJ"].ToString() + "的经营计划单变更需要查看!");
                            }
                        }
                        // DBCallCommon.SendEmail("", cs_list, new List<string>(), "经营计划单变更", "您有经营计划单变更需要查看!");

                        // 给王艳辉发邮件
                        //string str1 = "select a.*,b.ST_NAME from TBCM_PLAN as a left join TBDS_STAFFINFO as b on b.ST_ID=a.CM_MANCLERK where ID='" + id + "'";
                        //DataTable dt1 = DBCallCommon.GetDTUsingSqlText(str1);
                        //DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID("202"), new List<string>(), new List<string>(), "经营计划单变更", "合同号为“" + dt1.Rows[0]["CM_CONTR"].ToString() + "的经营计划单已经变更,请您上系统查看");
                        // 发送邮件
                        string    sql1 = "select ID,TSA_ID,TSA_ENGNAME,MTA_DUY,TSA_TCCLERKNM,QSA_QCCLERKNM from TBCM_BASIC as a left join View_TBMP_TASKASSIGN as b on a.TSA_ID=b.MTA_ID where ID=" + id;
                        DataTable dt3  = DBCallCommon.GetDTUsingSqlText(sql1);
                        if (dt.Rows.Count > 0)
                        {
                            DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(GetUesrID(dt3.Rows[0]["MTA_DUY"].ToString())), new List <string>(), new List <string>(), "经营计划单变更", "任务号“" + dt3.Rows[0]["TSA_ID"].ToString() + "“产品名称为" + dt3.Rows[0]["TSA_ENGNAME"].ToString() + "的经营计划单已经变更,请您上系统查看");
                            DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(GetUesrID(dt3.Rows[0]["TSA_TCCLERKNM"].ToString())), new List <string>(), new List <string>(), "经营计划单变更", "任务号“" + dt3.Rows[0]["TSA_ID"].ToString() + "“产品名称为" + dt3.Rows[0]["TSA_ENGNAME"].ToString() + "的经营计划单已经变更,请您上系统查看");
                            DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(GetUesrID(dt3.Rows[0]["QSA_QCCLERKNM"].ToString())), new List <string>(), new List <string>(), "经营计划单变更", "任务号“" + dt3.Rows[0]["TSA_ID"].ToString() + "“产品名称为" + dt3.Rows[0]["TSA_ENGNAME"].ToString() + "的经营计划单已经变更,请您上系统查看");
                        }
                        string resultvalid = "";
                        for (int k = 0; k < GridView1.Rows.Count; k++)
                        {
                            Label TSA_ID = (Label)GridView1.Rows[k].FindControl("TSA_ID");
                            if (!string.IsNullOrEmpty(TSA_ID.Text.ToString().Trim()))
                            {
                                resultvalid += TSA_ID.Text.ToString().Trim() + ",";
                            }
                        }

                        string    sqlquality = "select QSA_ENGID,QSA_TCCHGER,QSA_TCCHGERNM,QSA_QCCLERK,QSA_QCCLERKNM from View_TCTSASSGN_QTSASSGN where QSA_ENGID in ('" + resultvalid.Substring(0, resultvalid.Length - 1) + "') and QSA_QCCLERK is not null and QSA_QCCLERK<>''";
                        DataTable dtquality  = DBCallCommon.GetDTUsingSqlText(sqlquality);
                        for (int m = 0; m < dtquality.Rows.Count; m++)
                        {
                            DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dtquality.Rows[m]["QSA_TCCHGER"].ToString()), new List <string>(), new List <string>(), "经营计划单变更", "任务号为“" + resultvalid.Substring(0, resultvalid.Length - 1) + "”的经营计划单已经变更,请您查看相关质检任务分工!");
                            DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dtquality.Rows[m]["QSA_QCCLERK"].ToString()), new List <string>(), new List <string>(), "经营计划单变更", "任务号为“" + resultvalid.Substring(0, resultvalid.Length - 1) + "”的经营计划单已经变更,请您查看相关质检任务!");
                        }
                    }
                }
                else  //不同意
                {
                    if (txt_yj == "")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('驳回意见不能为空!');", true); return;
                    }
                    else
                    {
                        psyj = txt_yj;
                    }
                    sql = "update TBCM_CHANLIST set CM_STATE='3' where CH_ID='" + chId + "'";
                    str_sql.Add(sql);
                    DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_MANCLERK"].ToString()), new List <string>(), new List <string>(), "经营计划单被驳回", "您提交的经营计划单被驳回!请修改后再次提交");
                }
                sql = string.Format("update TBCM_CHANLIST set CM_PSYJ{0}='{1}',CM_PSSJ{0}='{2}',CM_NOTE{0}='{3}' where CH_ID='{4}'", psr, j, riqi, psyj, chId);
                str_sql.Add(sql);
                DBCallCommon.ExecuteTrans(str_sql);
                Response.Redirect("CM_ChangePS.aspx");
            }
        }
Exemple #7
0
        private void Control_All_Pal_Enable()
        {
            string username = Session["UserName"].ToString();

            //部门负责人
            string sqlbmfzr = "select DISTINCT ST_NAME,DEP_NAME,CRD_ID,CRD_PID,CRD_PSYJ,CRD_NOTE,CRD_SHSJ" +
                              " ,CRD_DEP from VIEW_TBCR_CONTRACTVIEW_AUDIT where CRD_ID='" + id + "'and CRD_PIDTYPE ='1' and  CRD_DEP!='01'";
            DataTable dt_bmfzr = DBCallCommon.GetDTUsingSqlText(sqlbmfzr);

            for (int i = 0; i < dt_bmfzr.Rows.Count; i++)
            {
                Panel pal = new Panel();
                pal = (Panel)TabContainer1.FindControl("TabPanel2").FindControl("Panel" + i.ToString());
                TextBox tbyj = (TextBox)TabContainer1.FindControl("TabPanel2").FindControl("txt_shyj" + i.ToString());

                Label    lb      = (Label)TabContainer1.FindControl("TabPanel2").FindControl("lb_shr" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1] && action == "audit")
                {
                    //对于审计部的人,其他部门都通过后审计才能审核
                    string    check_bmyj    = "select distinct CRD_PSYJ FROM VIEW_TBCR_CONTRACTVIEW_AUDIT WHERE CRD_ID='" + id + "'and CRD_DEP not in ('01','14') AND CRD_PSYJ='0'";
                    DataTable dt_check_bmyj = DBCallCommon.GetDTUsingSqlText(check_bmyj);
                    if ((Session["UserDeptID"].ToString() == "14" && dt_check_bmyj.Rows.Count == 0) || Session["UserDeptID"].ToString() != "14")
                    {
                        pal.Enabled      = true;
                        tbyj.BorderColor = System.Drawing.Color.Orange;
                        tbyj.Focus();
                        LbtnYes.Visible = true;
                        LbtnNO.Visible  = true;
                    }
                    else
                    {
                        pal.Enabled = false;
                    }
                }
                else
                {
                    pal.Enabled = false;
                }
            }

            //公司领导
            string sqlgsld = "select DISTINCT ST_NAME,DEP_NAME,CRD_ID,CRD_PID,CRD_PSYJ,CRD_NOTE,CRD_SHSJ" +
                             " ,CRD_DEP from VIEW_TBCR_CONTRACTVIEW_AUDIT where CRD_ID='" + id + "'and CRD_PIDTYPE ='1' and  CRD_DEP='01'";
            DataTable dt_gsld = DBCallCommon.GetDTUsingSqlText(sqlgsld);

            for (int i = 0; i < dt_gsld.Rows.Count; i++)
            {
                Panel pal = new Panel();
                pal = (Panel)TabContainer1.FindControl("TabPanel3").FindControl("Panel" + i.ToString());
                TextBox tbyj = (TextBox)TabContainer1.FindControl("TabPanel3").FindControl("txt_shyj_ld" + i.ToString());

                Label    lb      = (Label)TabContainer1.FindControl("TabPanel3").FindControl("lb_shr_ld" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1] && action == "audit")
                {
                    //对于公司领导,审计通过后才能审核
                    string    check_sjyj    = "select distinct CRD_PSYJ FROM VIEW_TBCR_CONTRACTVIEW_AUDIT WHERE CRD_ID='" + id + "'and CRD_DEP<>'01' AND CRD_PSYJ='0'";
                    DataTable dt_check_sjyj = DBCallCommon.GetDTUsingSqlText(check_sjyj);
                    if ((Session["UserDeptID"].ToString() == "01" && dt_check_sjyj.Rows.Count == 0) || Session["UserDeptID"].ToString() != "01")
                    {
                        pal.Enabled      = true;
                        tbyj.BorderColor = System.Drawing.Color.Orange;
                        tbyj.Focus();
                        LbtnYes.Visible = true;
                        LbtnNO.Visible  = true;
                    }
                    else
                    {
                        pal.Enabled = false;
                    }
                }
                else
                {
                    pal.Enabled = false;
                }
            }
        }
Exemple #8
0
        private void ExeSQL(int j)
        {
            List <string> strb_sql = new List <string>();
            string        psyj     = "";
            string        txt_yj   = "";                                  //意见文本框中的文字
            string        riqi     = DateTime.Now.ToString("yyyy-MM-dd"); //评审时间
            string        username = Session["UserName"].ToString();

            //评审人是部门负责人
            string sqlbmfzr = "select DISTINCT ST_NAME,DEP_NAME,CRD_ID,CRD_PID,CRD_PSYJ,CRD_NOTE,CRD_SHSJ" +
                              " ,CRD_DEP from VIEW_TBCR_CONTRACTVIEW_AUDIT where CRD_ID='" + id + "'and CRD_PIDTYPE ='1' and  CRD_DEP!='01'";
            DataTable dt_bmfzr = DBCallCommon.GetDTUsingSqlText(sqlbmfzr);

            for (int i = 0; i < dt_bmfzr.Rows.Count; i++)
            {
                Label    lb      = (Label)TabContainer1.FindControl("TabPanel2").FindControl("lb_shr" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1])
                {
                    TextBox txt_shyj = (TextBox)TabContainer1.FindControl("TabPanel2").FindControl("txt_shyj" + i.ToString());
                    txt_yj = txt_shyj.Text;
                }
            }

            //评审人是公司领导
            string sqlgsld = "select DISTINCT ST_NAME,DEP_NAME,CRD_ID,CRD_PID,CRD_PSYJ,CRD_NOTE,CRD_SHSJ" +
                             " ,CRD_DEP from VIEW_TBCR_CONTRACTVIEW_AUDIT where CRD_ID='" + id + "'and CRD_PIDTYPE ='1' and  CRD_DEP='01'";
            DataTable dt_gsld = DBCallCommon.GetDTUsingSqlText(sqlgsld);

            for (int i = 0; i < dt_gsld.Rows.Count; i++)
            {
                Label    lb      = (Label)TabContainer1.FindControl("TabPanel3").FindControl("lb_shr_ld" + i.ToString());
                string[] lb_text = lb.Text.Trim().Split(':');
                if (username == lb_text[1])
                {
                    TextBox txt_shyj = (TextBox)TabContainer1.FindControl("TabPanel3").FindControl("txt_shyj_ld" + i.ToString());
                    txt_yj = txt_shyj.Text;
                }
            }
            if (j == 1)
            {
                if (txt_yj == "")
                {
                    if (Session["UserDeptID"].ToString() != "01")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('驳回意见不能为空!');", true); return;
                    }
                    psyj = txt_yj;
                }
                else
                {
                    psyj = txt_yj;
                }
            }
            else
            {
                if (txt_yj == "")
                {
                    psyj = "同意";
                }
                else
                {
                    psyj = txt_yj;
                }
            }
            string sql = "update TBCR_CONTRACTREVIEW_DETAIL set CRD_PSYJ='" + j.ToString() + "',CRD_NOTE='" + psyj + "'" +
                         " ,CRD_SHSJ='" + riqi + "' where CRD_ID='" + id + "' and CRD_PID='" + Session["UserID"].ToString() + "'";

            strb_sql.Add(sql);

            //修改合同评审状态 评审完成2,已驳回3,
            //根据合同类型来修改相应的表
            string tbname = type == "8" ? "" : "TBCR_CONTRACTREVIEW";

            if (j == 1) //不同意
            {
                string str_back = "";
                if (type == "8")
                {
                    str_back = "update TBCM_ADDCON set CON_PSZT='3' where CR_ID='" + id + "'";
                }
                else
                {
                    str_back = "update TBCR_CONTRACTREVIEW set CR_PSZT='3' where CR_ID='" + id + "'";
                }
                strb_sql.Add(str_back);
                //发送邮件通知——审批驳回
                SendMail("no");
            }
            else //同意 如果除此人以外其他人都同意了,则审批状态改为审批完成
            {
                string str_check_over = "select * from TBCR_CONTRACTREVIEW_DETAIL where CRD_ID='" + id + "'" +
                                        " and CRD_PID!='" + Session["UserID"].ToString() + "' and CRD_PSYJ!='2'";
                DataTable dt_check = DBCallCommon.GetDTUsingSqlText(str_check_over);
                if (dt_check.Rows.Count == 0)
                {
                    string str_over = "";
                    if (type == "8")
                    {
                        str_over = "update TBCM_ADDCON set CON_PSZT='2' where CR_ID='" + id + "'";
                    }
                    else
                    {
                        str_over = "update TBCR_CONTRACTREVIEW set CR_PSZT='2' where CR_ID='" + id + "'";
                    }
                    strb_sql.Add(str_over);

                    //审批完成后将对应的合同签订日期改为评审通过日期
                    if (type != "8")
                    {
                        string str_updatevalidate = "update TBPM_CONPCHSINFO set PCON_FILLDATE ='" + riqi + "' where PCON_REVID='" + id + "'";
                        strb_sql.Add(str_updatevalidate);
                    }

                    //发送邮件通知——审批通过
                    SendMail("yes");
                }
            }
            DBCallCommon.ExecuteTrans(strb_sql);
            string    sqlcomcount = "select distinct(CRD_PID) from View_TBCR_View_Detail_ALL where  CRD_PID in ('1','2') and CR_PSZT in ('1','2') and CRD_PIDTYPE='1'and CR_ID='" + id + "'";
            DataTable dtcomcount  = DBCallCommon.GetDTUsingSqlText(sqlcomcount);

            string    sqlcom = "select CR_ID from View_TBCR_View_Detail_ALL where CRD_PSYJ='0' and CRD_PID  in ('1','2') and CR_PSZT in ('1','2') and CRD_PIDTYPE='1'and CR_ID='" + id + "'";
            DataTable dtcom  = DBCallCommon.GetDTUsingSqlText(sqlcom);

            if (dtcom.Rows.Count > 0)
            {
                if (dtcomcount.Rows.Count == dtcom.Rows.Count)
                {
                    string    sqldep = "select distinct(CR_ID) from View_TBCR_View_Detail_ALL where CRD_PSYJ='0' and CRD_PID not in ('1','2') and CR_PSZT in ('1','2') and CRD_PIDTYPE='1'and CR_ID='" + id + "'";
                    DataTable dtdep  = DBCallCommon.GetDTUsingSqlText(sqldep);
                    if (dtdep.Rows.Count == 0)
                    {
                        string _body = "合同审批任务:"
                                       + "\r\n合同号:" + lb_HTBH.Text.Trim()
                                       + "\r\n项目名称:" + lb_XMMC.Text.Trim();
                        string _subject = "您有新的【合同】需要审批,请及时处理";
                        string _emailto = "";
                        for (int k = 0; k < dtcom.Rows.Count; k++)
                        {
                            _emailto = DBCallCommon.GetEmailAddressByUserID(dtcomcount.Rows[k][0].ToString());
                            DBCallCommon.SendEmail(_emailto, null, null, _subject, _body);
                        }
                    }
                }
            }
        }
        private void ExeSQL(int j)
        {
            List <string> str_sql = new List <string>();
            string        sql     = "";
            string        psyj    = "";
            string        txt_yj  = "";                                  //意见文本框中的文字
            string        riqi    = DateTime.Now.ToString("yyyy-MM-dd"); //评审时间

            //评审人意见
            sql = "select * from TBCM_PLAN where ID='" + id + "'";
            DataTable dt  = DBCallCommon.GetDTUsingSqlText(sql);
            int       psr = 0;
            int       n   = 0;

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                n = int.Parse(dr["CM_PSJB"].ToString());
                for (int i = 0; i < n; i++)
                {
                    Label       lb       = (Label)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shr" + i);
                    TextBox     txt_shyj = (TextBox)TabContainer1.FindControl("Pan_ShenHe").FindControl("txt_shyj" + i);
                    HiddenField hd       = (HiddenField)TabContainer1.FindControl("Pan_ShenHe").FindControl("lb_shrid" + i.ToString());
                    if (UserID.Value == hd.Value)
                    {
                        txt_yj = txt_shyj.Text;
                        psr    = i + 1;
                        break;
                    }
                }

                //修改评审状态 评审完成2,已驳回3,
                //根据类型来修改相应的表
                if (j == 2)
                {
                    if (txt_yj == "")
                    {
                        psyj = "同意";
                    }
                    else
                    {
                        psyj = txt_yj;
                    }
                    //2016.9.20
                    //评审完之后,邮件提示下一个人有计划单需要审批
                    //if (psr < 3 && psr < n)
                    //{
                    //    DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_PS" + (psr + 1)].ToString()), new List<string>(), new List<string>(), "经营计划单评审", "您有经营计划单需要评审!");
                    //}

                    if (psr == n && dt.Rows[0]["CM_SPSTATUS"].ToString() == "1")
                    {
                        sql = "update TBCM_PLAN set CM_SPSTATUS='2' where ID='" + id + "'";
                        DBCallCommon.ExeSqlText(sql);
                        // str_sql.Add(sql);

                        #region 存入各表

                        //计划单审核通过插入销售合同
                        string    jhdtype  = "";
                        string    sqlstid  = "select TSA_ID from TBPM_DETAIL where CM_CONTR='" + CM_CONTR.Text.Trim() + "'";
                        DataTable stiddata = DBCallCommon.GetDTUsingSqlText(sqlstid);
                        if (stiddata.Rows.Count > 0)
                        {
                            jhdtype = "2";
                        }
                        else
                        {
                            jhdtype = "-1";
                        }
                        string    sqlshdata = "select a.*,b.CM_REFER as TSA_TYPENAME from TBCM_BASIC as a left join TBCM_TYPE as b on a.TSA_TYPE=b.CM_TYPE where ID='" + id + "' order by a.TSA_ID,a.CM_ID asc";
                        DataTable shdata    = DBCallCommon.GetDTUsingSqlText(sqlshdata);
                        for (int i = 0; i < shdata.Rows.Count; i++)
                        {
                            string TSA_ID       = shdata.Rows[i]["TSA_ID"].ToString();
                            string TSA_ENGNAME  = shdata.Rows[i]["TSA_ENGNAME"].ToString();
                            string TSA_MAP      = shdata.Rows[i]["TSA_MAP"].ToString();
                            string TSA_NUMBER   = shdata.Rows[i]["TSA_NUMBER"].ToString();
                            string TSA_UNIT     = shdata.Rows[i]["TSA_UNIT"].ToString();
                            string TSA_MATERIAL = shdata.Rows[i]["TSA_MATERIAL"].ToString();

                            string sqltext = "insert into TBPM_DETAIL(CM_CONTR,TSA_ID,CM_PROJ,CM_YZHTH,CM_ENGNAME,CM_MATERIAL,CM_MAP,CM_NUMBER,CM_UNIT,CM_JHDTYPE) values('" + CM_CONTR.Text.Trim() + "','" + TSA_ID.Trim() + "','" + CM_PROJ.Text.Trim() + "','" + CM_DFCONTR.Text.Trim() + "','" + TSA_ENGNAME.Trim() + "','" + TSA_MATERIAL.Trim() + "','" + TSA_MAP.Trim() + "','" + TSA_NUMBER.Trim() + "','" + TSA_UNIT.Trim() + "','" + jhdtype + "')";
                            str_sql.Add(sqltext);
                        }

                        //string cs = "select CM_PID from TBCM_PSVIEW where CM_ID='" + id + "' and CM_PIDTYPE='1'";
                        //DataTable cs_dt = DBCallCommon.GetDTUsingSqlText(cs);
                        //List<string> cs_list = new List<string>();
                        //for (int i = 0; i < cs_dt.Rows.Count; i++)
                        //{
                        //    cs_list.Add(DBCallCommon.GetEmailAddressByUserID(cs_dt.Rows[i][0].ToString()));
                        //}
                        //for (int i = 0; i < cs_list.Count; i++)
                        //{
                        //    DBCallCommon.SendEmail(cs_list[i], new List<string>(), new List<string>(), "经营计划单查看", "您有经营计划单需要查看!,合同号为" + CM_CONTR.Text);
                        //}

                        string engname = string.Empty;
                        sql = "select TSA_ID,TSA_ENGNAME,TSA_TYPE from TBCM_BASIC where ID='" + id + "' order by TSA_ID";
                        DataTable     task    = DBCallCommon.GetDTUsingSqlText(sql);
                        List <string> liststr = new List <string>();
                        string        fhdate  = dt.Rows[0]["CM_FHDATE"].ToString();
                        string        dhpart  = dt.Rows[0]["CM_COMP"].ToString();
                        if (task.Rows.Count > 0)
                        {
                            //for (int i = 0; i < task.Rows.Count; i++)
                            //{
                            //    liststr.Contains(task.Rows[i][0].ToString());
                            //}
                            //liststr = liststr.Distinct<string>().ToList();
                            liststr.Add(task.Rows[0][0].ToString());
                            string[] engs;
                            for (int i = 0; i < task.Rows.Count; i++)
                            {
                                if (liststr.Contains(task.Rows[i][0].ToString()))
                                {
                                    engname += "/" + task.Rows[i]["TSA_ENGNAME"].ToString();
                                }
                                else
                                {
                                    liststr.Add(task.Rows[i][0].ToString());
                                    engs = engname.Substring(1).Split('/');
                                    if (engs.Length > 3)
                                    {
                                        engname = "/" + engs[0] + "/" + engs[1] + "/" + engs[2] + "/...";
                                    }
                                    str_sql.Add(string.Format("insert into TBCB_BMCONFIRM(TASK_ID,PRJ,ENG,HT_ID) values('{0}','{1}','{2}','{3}')", task.Rows[i - 1][0], CM_PROJ.Text, engname.Substring(1), CM_CONTR.Text));
                                    str_sql.Add(string.Format("insert into TBPM_TCTSASSGN(ID,TSA_ID,TSA_PJID,TSA_ENGNAME,TSA_BUYER,TSA_CONTYPE,TSA_DELIVERYTIME,TSA_DESIGNCOM) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", id, task.Rows[i - 1][0], CM_CONTR.Text, engname.Substring(1), CM_COMP.Text, task.Rows[i - 1]["TSA_TYPE"].ToString(), fhdate, dhpart));
                                    str_sql.Add(string.Format("insert into TBMP_MANUTSASSGN(MTA_ID,MTA_PJID,MTA_ENGNAME) values('{0}','{1}','{2}')", task.Rows[i - 1][0], CM_CONTR.Text, engname.Substring(1)));
                                    str_sql.Add(string.Format("insert into TBQM_QTSASSGN(QSA_ENGID) values('{0}')", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANTOTAL(MP_CODE,MP_PJID,MP_PJNAME,MP_ENGNAME,MP_STARTDATE,MP_DELIVERYDATE) values('{0}','{1}','{2}','{3}','{4}','{5}')", task.Rows[i - 1][0], CM_CONTR.Text, CM_PROJ.Text, engname.Substring(1), DateTime.Now.ToString("yyyy-MM-dd"), fhdate));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','材料计划','技术准备',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','制作明细','技术准备',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','成品入库','生产周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','非定尺板','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','定尺板','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','耐磨板','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','型材','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','圆钢','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','标准件','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','铸件','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','锻件','采购周期',0)", task.Rows[i - 1][0]));
                                    str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','采购成品','采购周期',0)", task.Rows[i - 1][0]));
                                    engname = "/" + task.Rows[i]["TSA_ENGNAME"].ToString();
                                }
                            }
                            engs = engname.Substring(1).Split('/');
                            if (engs.Length > 3)
                            {
                                engname = "/" + engs[0] + "/" + engs[1] + "/" + engs[2] + "/...";
                            }
                            str_sql.Add(string.Format("insert into TBCB_BMCONFIRM(TASK_ID,PRJ,ENG,HT_ID) values('{0}','{1}','{2}','{3}')", task.Rows[task.Rows.Count - 1][0], CM_PROJ.Text, engname.Substring(1), CM_CONTR.Text));
                            str_sql.Add(string.Format("insert into TBPM_TCTSASSGN(ID,TSA_ID,TSA_PJID,TSA_ENGNAME,TSA_BUYER,TSA_CONTYPE,TSA_DELIVERYTIME,TSA_DESIGNCOM) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", id, task.Rows[task.Rows.Count - 1][0], CM_CONTR.Text, engname.Substring(1), CM_COMP.Text, task.Rows[task.Rows.Count - 1]["TSA_TYPE"].ToString(), fhdate, dhpart));
                            str_sql.Add(string.Format("insert into TBMP_MANUTSASSGN(MTA_ID,MTA_PJID,MTA_ENGNAME) values('{0}','{1}','{2}')", task.Rows[task.Rows.Count - 1][0], CM_CONTR.Text, engname.Substring(1)));
                            str_sql.Add(string.Format("insert into TBQM_QTSASSGN(QSA_ENGID) values('{0}')", task.Rows[task.Rows.Count - 1][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANTOTAL(MP_CODE,MP_PJID,MP_PJNAME,MP_ENGNAME,MP_STARTDATE,MP_DELIVERYDATE) values('{0}','{1}','{2}','{3}','{4}','{5}')", task.Rows[task.Rows.Count - 1][0], CM_CONTR.Text, CM_PROJ.Text, engname.Substring(1), DateTime.Now.ToString("yyyy-MM-dd"), fhdate));//
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','材料计划','技术准备',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','制作明细','技术准备',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','成品入库','生产周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','非定尺板','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','定尺板','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','耐磨板','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','型材','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','圆钢','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','标准件','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','铸件','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','锻件','采购周期',0)", task.Rows[0][0]));
                            str_sql.Add(string.Format("insert into TBMP_MAINPLANDETAIL(MP_ENGID,MP_PLNAME,MP_TYPE,MP_STATE) values('{0}','采购成品','采购周期',0)", task.Rows[0][0]));
                        }

                        #endregion
                    }

                    //评审完之后,邮件提示下一个人有计划单需要审批,全部结束,发送抄送人
                    if (psr < 3 && psr < n)
                    {
                        DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_PS" + (psr + 1)].ToString()), new List <string>(), new List <string>(), "经营计划单评审", "您有经营计划单需要评审!");
                    }

                    if (psr == n && dt.Rows[0]["CM_SPSTATUS"].ToString() == "1")
                    {
                        string        cs      = "select CM_PID from TBCM_PSVIEW where CM_ID='" + id + "' and CM_PIDTYPE='1'";
                        DataTable     cs_dt   = DBCallCommon.GetDTUsingSqlText(cs);
                        List <string> cs_list = new List <string>();
                        for (int i = 0; i < cs_dt.Rows.Count; i++)
                        {
                            cs_list.Add(DBCallCommon.GetEmailAddressByUserID(cs_dt.Rows[i][0].ToString()));
                        }
                        for (int i = 0; i < cs_list.Count; i++)
                        {
                            DBCallCommon.SendEmail(cs_list[i], new List <string>(), new List <string>(), "经营计划单查看", "您有经营计划单需要查看!,合同号为" + CM_CONTR.Text);
                        }
                    }
                }
                else  //不同意
                {
                    if (txt_yj == "")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, GetType(), "", "alert('驳回意见不能为空!');", true); return;
                    }
                    else
                    {
                        psyj = txt_yj;
                    }
                    sql = "update TBCM_PLAN set CM_SPSTATUS='3' where ID='" + id + "'";
                    //sql = "update TBCM_PLAN set CM_SPSTATUS='3' where ID='"+id+"'";
                    str_sql.Add(sql);
                    DBCallCommon.SendEmail(DBCallCommon.GetEmailAddressByUserID(dt.Rows[0]["CM_MANCLERK"].ToString()), new List <string>(), new List <string>(), "经营计划单被驳回", "您提交的经营计划单被驳回!请修改后再次提交");
                }
                sql = string.Format("update TBCM_PLAN set CM_PSYJ{0}='{1}',CM_PSSJ{0}='{2}',CM_NOTE{0}='{3}' where ID='{4}'", psr, j, riqi, psyj, id);
                str_sql.Add(sql);
                DBCallCommon.ExecuteTrans(str_sql);
            }
        }