Пример #1
0
        /// <summary>
        /// 编辑WS信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("WSRR");

            try
            {
                if(m_request == null
                    || m_request.Tables.Count==0
                    || m_request.Tables[0].Rows.Count == 0)
                {
                    return true;
                }
                string strParam_ID = m_request.Tables[0].Rows[0]["Param_ID"].ToString();
                
                ArrayList listTable = new ArrayList();
                listTable.Add("WS_Param");
                conn.BeginTransaction();
                conn.TableLock(listTable);
                string strWhere = " Param_ID = '" + strParam_ID + "'";

                conn.Delete("WS_Param", strWhere);
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
Пример #2
0
        /// <summary>
        /// 编辑系统属性信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");

            try
            {
                string strProperty_ID = m_request.Tables[0].Rows[0]["Property_ID"].ToString();
                m_request.Tables[0].Columns.Remove("Property_ID");

                ArrayList listTable = new ArrayList();
                listTable.Add("MDM_System_Property");
                conn.BeginTransaction();
                conn.TableLock(listTable);

                if (strProperty_ID == "")
                {
                    conn.Insert("MDM_System_Property", m_request.Tables[0]);
                }
                else
                {
                    string strWhere = " Property_ID=" + strProperty_ID;
                    conn.Update("MDM_System_Property", m_request.Tables[0], strWhere);
                }
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
        /// <summary>
        /// 删除系统权限信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");

            try
            {
                string strAuthorization_ID = m_request.Tables[0].Rows[0]["Authorization_ID"].ToString();
                m_request.Tables[0].Columns.Remove("Authorization_ID");

                ArrayList listTable = new ArrayList();
                listTable.Add("MDM_System_Authorization");
                listTable.Add("MDM_System_Menu_AUZ");
                conn.BeginTransaction();
                conn.TableLock(listTable);

                if (strAuthorization_ID != "")
                {
                    string strWhere = " Authorization_ID=" + strAuthorization_ID;
                    conn.Delete("MDM_System_Authorization", strWhere);
                    conn.Delete("MDM_System_Menu_AUZ", strWhere);
                }
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
Пример #4
0
        /// <summary>
        /// 获取系统环境信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");

            try
            {
                string strEnv_ID = m_request.Tables[0].Rows[0]["Env_ID"].ToString();
                string strEnv_SN = m_request.Tables[0].Rows[0]["Env_SN"].ToString();
                m_request.Tables[0].Columns.Remove("Env_ID");

                ArrayList listTable = new ArrayList();
                listTable.Add("MDM_System_Env");
                conn.BeginTransaction();
                conn.TableLock(listTable);

                 //核对环境简称是否存在
                string strSQL = "SELECT 1 AS a FROM MDM_System_Env where Env_SN='" + strEnv_SN + "'";
                if(strEnv_ID != "")
                {
                    strSQL += " AND Env_ID !=" + strEnv_ID;
                }

                DataTable dtTemp = conn.GetDataTableInTrans(strSQL);
                if (dtTemp.Rows.Count > 0)
                {
                    throw new Exception(strEnv_SN + "已存在!");
                }

                if (strEnv_ID == "")
                {
                    conn.Insert("MDM_System_Env", m_request.Tables[0]);
                }
                else
                {
                    string strWhere = " Env_ID=" + strEnv_ID;
                    conn.Update("MDM_System_Env", m_request.Tables[0], strWhere);
                }
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
        /// <summary>
        /// 供销售日报使用
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {

            Dbconn conn_PLM_AS = new Dbconn("F22GP_ForSalesPlan");
            DataSet ds = conn_PLM_AS.GetDataSet(
                @"  SELECT  94 AS Env_ID , --HZY_Sale_Report
                            null AS VexSSONewID ,
                            b.userid AS App_UserName ,
                            RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5', CONVERT(VARCHAR(100), b.password))), 32) AS App_Password ,
                            b.password AS App_PasswordSrc ,
                            b.username AS App_UserName_CN ,
                            GETDATE() Chang_Password_Time ,
                            1 Checked ,
                            'system' Check_User ,
                            GETDATE() Check_Time ,
                            GETDATE() Createtime ,
                            GETDATE() Updatetime
                    FROM    j_depot a ,
                            j_user b
                    WHERE   a.depotid = b.depotid
                            AND a.m_type = 11
                     ");

            Dbconn connMDM = new Dbconn("VexSSO");

            try
            {


                ArrayList tableList = new ArrayList();
                connMDM.BeginTransaction();

                tableList.Add("MDM_System_User");
                connMDM.TableLock(tableList);

                //删除数据
                connMDM.ExcuteQuerryByTran(@"DELETE FROM MDM_System_User WHERE ENV_ID=94");

                connMDM.InsertBYSQLBC("MDM_System_User", ds.Tables[0]);
                connMDM.CommitTransaction();
                return true;
            }
            catch
            {
                connMDM.RollbackTransaction();
                throw;
            }
        }
        /// <summary>
        /// 编辑系统属性值信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");

            try
            {
                string strSystem_ID = m_request.Tables[0].Rows[0]["System_ID"].ToString();
                string strSystem_Code = m_request.Tables[0].Rows[0]["System_Code"].ToString();

                DataTable dt_Add = new DataTable();
                dt_Add.Columns.Add("System_ID");
                dt_Add.Columns.Add("System_Code");
                dt_Add.Columns.Add("Property_ID");
                dt_Add.Columns.Add("Property_Text");
                for (int i = 2; i < m_request.Tables[0].Columns.Count; i++)
                {
                    string strValue = m_request.Tables[0].Rows[0][i].ToString();
                    if (strValue != "")
                    {
                        dt_Add.Rows.Add(new object[] { strSystem_ID, strSystem_Code, m_request.Tables[0].Columns[i].ToString(),strValue});
                    }
                }


                ArrayList listTable = new ArrayList();
                listTable.Add("MDM_System_Property_info");
                conn.BeginTransaction();
                conn.TableLock(listTable);
                string strWhere = " System_ID=" + strSystem_ID;
                conn.Delete("MDM_System_Property_info", strWhere);

                conn.InsertBYSQLBC("MDM_System_Property_info", dt_Add);
                
                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
Пример #7
0
        /// <summary>
        /// 删除任务信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");

            try
            {
                if (m_request == null
                    || m_request.Tables.Count == 0
                    || m_request.Tables[0].Rows.Count == 0)
                {
                    return true;
                }
                string strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString();  //获取参数TASK_ID

                ArrayList listTable = new ArrayList();
                listTable.Add("WS_Scheduling");
                conn.BeginTransaction();    //事物事务
                conn.TableLock(listTable);  //锁表WS_Scheduling

                DataTable dt_Add = new DataTable() ;
                dt_Add.Columns.Add("IsDeleted");
                dt_Add.Columns.Add("Enabled");
                dt_Add.Columns.Add("UpdateUser");
                dt_Add.Columns.Add("UpdateTime");

                DataRow dr = dt_Add.NewRow();
                dr["IsDeleted"] = "True";   //将删除标志设为“True”
                dr["Enabled"] = "False";    //将可用标志设为“False”
                dr["UpdateTime"]=DateTime.Now;  //更新时间设为当前时间
                dr["UpdateUser"] = hzyMessage.User_Name;    //设置更新者
                dt_Add.Rows.Add(dr);

                string strWhere = " TASK_ID = '" + strTASK_ID + "'";
                conn.Update("WS_Scheduling", dt_Add, strWhere); //更新操作

                conn.CommitTransaction();   //提交事务
                return true;
            }
            catch
            {
                conn.RollbackTransaction(); //回滚
                throw;
            }
        }
Пример #8
0
        /// <summary>
        /// 删除任务参数信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");    //创建连接类

            try
            {
                if (m_request == null
                    || m_request.Tables.Count == 0
                    || m_request.Tables[0].Rows.Count == 0)
                {
                    return true;
                }
                string strParam_ID = m_request.Tables[0].Rows[0]["param_id"].ToString();    //获取参数Param_ID
                string strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString();  //获取参数Task_ID

                ArrayList listTable = new ArrayList();
                listTable.Add("WS_SchedulingParam");
                conn.BeginTransaction();    //开启事务
                conn.TableLock(listTable);  //锁表WS_SchedulingParam

                string strWhere = " Param_ID = '" + strParam_ID + "'";  //创建where语句
                conn.Delete("WS_SchedulingParam", strWhere);    //删除参数

                //更新主表
                DataTable dtScheduling = new DataTable();
                dtScheduling.Columns.Add("UpdateTime");
                DataRow drScheduling = dtScheduling.NewRow();
                drScheduling["UpdateTime"] = DateTime.Now;
                dtScheduling.Rows.Add(drScheduling);
                string strSchedulingWhere = " 1=1 AND TASK_ID = '" + strTASK_ID + "'";
                conn.Update("WS_Scheduling", dtScheduling, strSchedulingWhere);    //更新数据

                conn.CommitTransaction();   //提交事务
                return true;
            }
            catch
            {
                conn.RollbackTransaction(); //回滚
                throw;
            }



        }
Пример #9
0
        /// <summary>
        /// 对CFG_RequestType的CRUD,为Easyui专用
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {

            DateTime time = DateTime.Now;

            Dbconn conn = new Dbconn("VexSSO");
            conn.LockTableList.Add("SSO_Login");
            conn.BeginTransaction();
            conn.TableLock();

            string strSQL = @"
                                UPDATE dbo.SSO_Login
                                SET Logout_Time='" + time.ToString("yyyy-MM-dd HH:mm:ss.fff")+ @"',
                                MARK='SYSTEM'
                                WHERE Last_Request_Time<='" + time.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss.fff") + @"'
                                    AND Logout_Time IS NULL
                            ";

            conn.ExcuteQuerryByTran(strSQL);
            conn.CommitTransaction();


            return true ;
        }
Пример #10
0
        /// <summary>
        /// 根据XML内容更新合同
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "ISNULL(PR0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @"SELECT  
                                     [PR0_CONO]
                                    ,[PR0_DIVI]
                                    ,[PR0_ContractId]
                                    ,[PR0_ContractCode]
                                    ,[PR0_SU0_SupplierId]
                                    ,CAST([PR0_Amount] AS DECIMAL(20,2)) as  PR0_Amount
                                    ,[PR0_CurrencyId]
                                    ,[PR0_Description]
                                    ,[PR0_Status]
                                    ,[PR0_ECopyPath]
                                    ,[PR0_PrePayRate]
                                    ,LEFT(CONVERT(VARCHAR(20),[PR0_StartDate],121),10) AS PR0_StartDate
                                    ,LEFT(CONVERT(VARCHAR(20),[PR0_EndDate],121),10) AS PR0_EndDate  
                                    ,[PR0_RgUser]
                                    ,[PR0_RgDt]
                                    ,[PR0_LmUser]
                                    ,[PR0_LmDt]
                                    ,[PR0_UptNo]
                                    ,[PR0_SettleAccount]
                                    ,[PR0_Total]
                                    ,A.[SU0_SupplierCode] as SU0_SupplierCode
                                    ,A.[SU0_SupplierName] as SU0_SupplierName
                                    ,B.WFT_NODE AS WFT_NODE1
                                    ,C.WFT_NODE AS WFT_NODE2
                                    ,D.WFT_NODE AS WFT_NODE3
                                    ,E.WFT_NODE AS WFT_NODE4
                                    ,F.WFT_NODE AS WFT_NODE5
                                    ,L.DC0_DICTNAME1 AS DC0_DICTNAME1
                                    ,M.DC0_DICTNAME1 AS DC0_DICTNAME2
                                    ,N.DC0_DICTNAME1 AS DC0_DICTNAME3
                                    ,O.DC0_DICTNAME1 AS DC0_DICTNAME4
                                    ,P.DC0_DICTNAME1 AS DC0_DICTNAME5
                                    ,G.WFP_AuditTime AS WFP_AuditTime1
                                    ,H.WFP_AuditTime AS WFP_AuditTime2 
                                    ,I.WFP_AuditTime AS WFP_AuditTime3
                                    ,J.WFP_AuditTime AS WFP_AuditTime4
                                    ,K.WFP_AuditTime AS WFP_AuditTime5 
                                    ,G.WFP_AFID AS WFP_AFID1
                                    ,H.WFP_AFID AS WFP_AFID2 
                                    ,I.WFP_AFID AS WFP_AFID3
                                    ,J.WFP_AFID AS WFP_AFID4
                                    ,K.WFP_AFID AS WFP_AFID5  
                                    ,Q.[DC0_DictName1] AS CurrencyDictName
                                    ,R.[DC0_DictName1] AS StatusDictName
                                    ,S.[DC0_DictName1] AS AccountDictName
                                FROM   B02_Bill.PR0_Contract WITH ( NOLOCK )  
                                LEFT JOIN  B01_MDM.SU0_Supplier A        ON    PR0_SU0_SupplierId=A.SU0_SupplierId  
                                LEFT JOIN  M02_BPM.WFT_AuditFlowDefine B ON    B.WFT_Type='Contract' and B.WFT_Step='1'
                                LEFT JOIN  M02_BPM.WFT_AuditFlowDefine C ON    C.WFT_Type='Contract' and C.WFT_Step='2'
                                LEFT JOIN  M02_BPM.WFT_AuditFlowDefine D ON    D.WFT_Type='Contract' and D.WFT_Step='3'
                                LEFT JOIN  M02_BPM.WFT_AuditFlowDefine E ON    E.WFT_Type='Contract' and E.WFT_Step='4'
                                LEFT JOIN  M02_BPM.WFT_AuditFlowDefine F ON    F.WFT_Type='Contract' and F.WFT_Step='5'
                                LEFT JOIN  M02_BPM.WFP_AuditFlow G       ON    PR0_ContractId=G.WFP_BillId AND G.WFP_WFT_AFDId=B.WFT_AFDId
                                LEFT JOIN  M02_BPM.WFP_AuditFlow H       ON    PR0_ContractId=H.WFP_BillId AND H.WFP_WFT_AFDId=C.WFT_AFDId
                                LEFT JOIN  M02_BPM.WFP_AuditFlow I       ON    PR0_ContractId=I.WFP_BillId AND I.WFP_WFT_AFDId=D.WFT_AFDId
                                LEFT JOIN  M02_BPM.WFP_AuditFlow J       ON    PR0_ContractId=J.WFP_BillId AND J.WFP_WFT_AFDId=E.WFT_AFDId
                                LEFT JOIN  M02_BPM.WFP_AuditFlow K       ON    PR0_ContractId=K.WFP_BillId AND K.WFP_WFT_AFDId=F.WFT_AFDId
                                LEFT JOIN  M01_CONF.DC0_Dictionary L     ON    G.WFP_AFResultId=L.DC0_DictId 
                                LEFT JOIN  M01_CONF.DC0_Dictionary M     ON    H.WFP_AFResultId=M.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary N     ON    I.WFP_AFResultId=N.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary O     ON    J.WFP_AFResultId=O.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary P     ON    K.WFP_AFResultId=P.DC0_DictId                             
                                LEFT JOIN  M01_CONF.DC0_Dictionary Q     ON    PR0_CurrencyId=Q.DC0_DictId   
                                LEFT JOIN  M01_CONF.DC0_Dictionary R     ON    PR0_Status=R.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary S     ON    PR0_SettleAccount=S.DC0_DictId   
                                WHERE " + strWHERE
                                + @"ORDER BY [PR0_LmDt] DESC "; 
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B02_Bill.PR0_Contract");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B02_Bill.PR0_Contract SET PR0_Status='E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                               WHERE PR0_ContractId='" + ds.Tables["LIST"].Rows[i]["PR0_ContractId"].ToString() + @"'
                                AND ISNULL(PR0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                  ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B02_Bill.PR0_Contract WHERE  PR0_ContractId=@param0
                                  AND ISNULL(PR0_Status,'') <>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PR0_ContractId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {

                                    strSQL = @"SELECT * FROM M02_BPM.WFP_AuditFlow  WHERE  WFP_BillId=@param0
                                         AND  WFP_AFResultId<>''
                                             ";

                                    DataTable dt_CO = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PR0_ContractId"].ToString() });
                                //update
                                 if (dt_CO.Rows.Count > 0)
                                 {
                                     throw new Exception("合同已审核,不能进行修改!");      
                                 }
                                 else

                                     //处理结果
                                     if (ds.Tables["LIST"].Rows[i]["PR0_LmUser"].ToString() != "")
                                     {
                                         string strCode = dt_SR.Rows[0]["PR0_UptNo"].ToString();
                                         if (strCode == "0")
                                         {
                                             strCode = Convert.ToInt32(strCode) + 1.ToString();
                                         }
                                         else
                                         {
                                             strCode = "0";
                                         }

                                         if (!dt.Columns.Contains("PR0_LmDt"))
                                         {
                                             dt.Columns.Add("PR0_LmDt");
                                         }
                                        // if (!dt.Columns.Contains("PR0_Status"))
                                        // {
                                       //      dt.Columns.Add("PR0_Status");
                                       //  }

                                         if (!dt.Columns.Contains("PR0_UptNo"))
                                         {
                                             dt.Columns.Add("PR0_UptNo");
                                         }

                                        // dt.Rows[0]["PR0_Status"] = '0';
                                         dt.Rows[0]["PR0_LmDt"] = DateTime.Now;
                                         dt.Rows[0]["PR0_UptNo"] = strCode;
                                     }

                                 conn.Update("B02_Bill.PR0_Contract", dt, "PR0_ContractId='" + ds.Tables["LIST"].Rows[i]["PR0_ContractId"].ToString() + @"'");

                                }
                                else  //add
                                {


                                    DataTable dtTemp = conn.GetDataTableInTrans(
                                    @"SELECT  ISNULL(MAX(PR0_ContractCode),'')  AS MaxCode,
                                      RIGHT(left( CONVERT(VARCHAR(100),DateAdd(m,+0,GETDATE()),112),4),2)+'-'+
                                      LEFT(RIGHT( CONVERT(VARCHAR(100),DateAdd(m,+0,GETDATE()),112),4),2) as PreCode FROM B02_Bill.PR0_Contract where 
                                      left(PR0_ContractCode,'2')=RIGHT(left( CONVERT(VARCHAR(100),DateAdd(m,+0,GETDATE()),112),4),2)
                                      AND left(right(PR0_ContractCode,'4'),'2')=LEFT(RIGHT( CONVERT(VARCHAR(100),DateAdd(m,+0,GETDATE()),112),4),2) ");
                                    //供应商编号生成
                                    string strCode = dtTemp.Rows[0]["MaxCode"].ToString();
                                    if (strCode == "")
                                    {
                                        strCode = dtTemp.Rows[0]["PreCode"].ToString() + "01";
                                      //  strCode = strCode.Substring(strCode.Substring(DateTime.Now.ToString().Length + 4).Length + 4)
                                            
                                       //     RIGHT(left(DateTime.Now.ToString(), 4), 2) + "-" + RIGHT(left(DateTime.Now.ToString(), 7), 2) + "01";
                                        //dtTemp.Rows[0]["PreCode"].ToString() + "0001";
                                    }
                                    else
                                    {
                                        strCode = dtTemp.Rows[0]["PreCode"].ToString() + (Convert.ToInt32(strCode.Substring(strCode.Length - 2)) + 1).ToString("00"); 
                                        //strCode = left(strCode, 2) + "-" + left(RIGHT(strCode, 4), 2) + (Convert.ToInt32(strCode.Substring(strCode.Length - 2)) + 1).ToString("00"); 
                                          //  dtTemp.Rows[0]["PreCode"].ToString() + (Convert.ToInt32(strCode.Substring(strCode.Length - 4)) + 1).ToString("0000");
                                    }


                                    string PR0_ContractId = Guid.NewGuid().ToString();


                                    if (!dt.Columns.Contains("PR0_ContractId"))
                                    {
                                        dt.Columns.Add("PR0_ContractId");
                                    }

                                  //  if (!dt.Columns.Contains("PR0_Status"))
                                   // {
                                   //     dt.Columns.Add("PR0_Status");
                                 //   }

                                    if (!dt.Columns.Contains("PR0_RgDt"))
                                    {
                                        dt.Columns.Add("PR0_RgDt");
                                    }

                                    if (!dt.Columns.Contains("PR0_LmDt"))
                                    {
                                        dt.Columns.Add("PR0_LmDt");
                                    }

                                    if (!dt.Columns.Contains("PR0_ContractCode"))
                                    {
                                        dt.Columns.Add("PR0_ContractCode");
                                    }

                                    if (!dt.Columns.Contains("PR0_UptNo"))
                                    {
                                        dt.Columns.Add("PR0_UptNo");
                                    }


                                    dt.Rows[0]["PR0_ContractId"] = PR0_ContractId;
                                 //   dt.Rows[0]["PR0_Status"] = '0';
                                    dt.Rows[0]["PR0_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["PR0_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["PR0_ContractCode"] = strCode;
                                    dt.Rows[0]["PR0_UptNo"] = '0';
                                    conn.Insert("B02_Bill.PR0_Contract", dt); 

                                    GL_ERP_Common clsCommon = new GL_ERP_Common();

                                    GL_ERP_Common.CreateWorkFlow(conn, "Contract", ds.Tables["LIST"].Rows[i]["PR0_CONO"].ToString(), ds.Tables["LIST"].Rows[i]["PR0_DIVI"].ToString(), PR0_ContractId,
                                     "Contract", "", "", ds.Tables["LIST"].Rows[i]["PR0_Status"].ToString(), ds.Tables["LIST"].Rows[i]["PR0_RgUser"].ToString(),
                                     ds.Tables["LIST"].Rows[i]["PR0_LmUser"].ToString(), "", "PR0_ContractId", "B02_Bill.PR0_Contract");
          
                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
        public bool Execute()
        {

            Dbconn conn = new Dbconn("AM");
            DataSet ds = conn.GetDataSet(
                @"SELECT  cn_id as AM_User_id,
                        CN_LOGIN as AM_login,
                        CN_USER_NAME as AM_User_Name,
                        CN_PASSWORD AM_Password,
                        CN_EMAIL AM_Email,
                        CN_TITLE AM_Title,
                        CN_HANDSET AM_Handset,
                        CN_ISDELETE AM_IsDelete

                FROM    dbo.TN_SYS_EM_USER t1 ,
                         dbo.TN_SYS_EM_USER_PROP t2
                WHERE   t1.cn_id = t2.CN_USERID
	");



            Dbconn connMDM = new Dbconn("MDM");

            try
            {


                ArrayList tableList = new ArrayList();
                connMDM.BeginTransaction();

                tableList.Add("AM_User_log");
                tableList.Add("AM_User");
                connMDM.TableLock(tableList);


//                //存入日志数据
//                connMDM.ExcuteQuerryByTran(@"INSERT  INTO dbo.AM_User_log
//                (   Log_datetime ,
//                    AM_User_id ,
//                    AM_LOGIN ,
//                    AM_USER_NAME,
//                    AM_PASSWORD,
//                    AM_EMAIL,
//                    AM_TITLE,
//                    AM_HANDSET,
//                    AM_ISDELETE,
//                    CreateTime ,
//                    UpdateTime ,
//                    Timestamps_old
//		        
//                )
//                SELECT  GETDATE() ,
//                        AM_User_id ,
//                        AM_LOGIN ,
//                        AM_USER_NAME,
//                        AM_PASSWORD,
//                        AM_EMAIL,
//                        AM_TITLE,
//                        AM_HANDSET,
//                        AM_ISDELETE,
//                        CreateTime ,
//                        UpdateTime,
//                        CONVERT(BIGINT,Timestamps)
//                FROM    AM_User;");
                //删除数据
                connMDM.ExcuteQuerryByTran("DELETE  FROM AM_User");
                connMDM.InsertBYSQLBC("AM_User", ds.Tables[0]);

                //更新MDM_Employees的用户信息
                connMDM.ExcuteQuerryByTran(@"UPDATE MDM_Employees 
                                    SET SSO_Password=t2.AM_Password,
                                    Leave_Flag=AM_ISDELETE
                                    FROM dbo.AM_User t2 WHERE MDM_Employees.SSO_UserName = t2.AM_login
                                    "
                    );


                //并添加新入职的数据
                connMDM.ExcuteQuerryByTran(@" 
                    INSERT INTO dbo.MDM_Employees
                            ( 
                              Name ,
                              Sex ,
                              Phone ,
                              Moblie ,
                              SSO_UserName ,
                              SSO_Password ,
                              In_Time ,
                              Leave_Time ,
                              Leave_Flag ,
                              IsActived 
                            )
                    SELECT  
                            AM_login ,
                            NULL,
                            NULL,
                            NULL,
                            AM_login ,
                            AM_Password ,
                            GETDATE(),
                            
                            NULL,
                            AM_ISDELETE,
                            1 FROM dbo.AM_User
                    WHERE AM_login NOT IN (SELECT SSO_UserName FROM MDM_Employees)
"
                    );
                connMDM.CommitTransaction();
                return true;
            }
            catch
            {
                connMDM.RollbackTransaction();
                throw;
            }
        }
        public bool Execute()
        {
            Dbconn conn = new Dbconn("iCollecter");
            DataSet ds = conn.GetDataSet(
                @"  SELECT  AMLoginName AS CN_LOGIN,TfgMachineNo,ComputerName
                    FROM    ( SELECT    ROW_NUMBER() OVER ( PARTITION BY TfgMachineNo ORDER BY collectDate DESC ) AS RowIndex ,
                                        ComputerName ,
                                        AMLoginName,
                                        TfgMachineNo
                              FROM      dbo.AMAndTFG WITH(NOLOCK)
                              WHERE     1 = 1
                                        AND ISNULL(AMLoginUsers, '') <> ''
                            ) t
                    WHERE   RowIndex = 1
 	                    ");



            Dbconn connMDM = new Dbconn("MDM");


            //获取用户ID
            ds.Tables[0].Columns.Add("AM_User_id", typeof(Int32));

            ds.Tables[0].AcceptChanges();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string[] strParm = new string[1];
                strParm[0]=ds.Tables[0].Rows[i]["CN_LOGIN"].ToString();

                DataTable dt = connMDM.GetDataTable("SELECT AM_User_id FROM AM_User WHERE AM_login=@Param0", strParm);
                if (dt.Rows.Count > 0)
                {
                    ds.Tables[0].Rows[i]["AM_User_id"] = dt.Rows[0]["AM_User_id"];
                }
                else
                {
                    ds.Tables[0].Rows[i].Delete();
                }

            }

            ds.Tables[0].Columns.Remove("CN_LOGIN");
            ds.Tables[0].AcceptChanges();
            try
            {


                ArrayList tableList = new ArrayList();
                connMDM.BeginTransaction();

                tableList.Add("AM_TFG_Relation_log");
                tableList.Add("AM_TFG_Relation");
                connMDM.TableLock(tableList);


                //存入日志数据
                connMDM.ExcuteQuerryByTran(@"INSERT  INTO dbo.AM_TFG_Relation_log
                ( Log_datetime ,
                  AM_User_id ,
                  TfgMachineNo ,
                  ComputerName ,
                  CreateTime ,
                  UpdateTime ,
                  Timestamps_old
		        
                )
                SELECT  GETDATE() ,
                        AM_User_id ,
                        TfgMachineNo ,
                        ComputerName ,
                        CreateTime ,
                        UpdateTime,
                        Convert(bigint,Timestamps)
                FROM    AM_TFG_Relation;");


                //删除数据
                connMDM.ExcuteQuerryByTran("DELETE  FROM AM_TFG_Relation");
                connMDM.Insert("AM_TFG_Relation", ds.Tables[0]);
                connMDM.CommitTransaction();

                return true;

            }
            catch
            {
                connMDM.RollbackTransaction();
                throw;
            }
        }
Пример #13
0
    /// <summary>
    /// 登出操作
    /// </summary>
    /// <param name="pSessionID"></param>
    /// <returns></returns>
    private bool DoLogout(string pSessionID)
    {
        bool returnValue = false;
        Dbconn conn = new Dbconn("VexSSO");

        DataTable dt = new System.Data.DataTable();
        dt.Columns.Add("Logout_Time");
        dt.Rows.Add(new object[] { DateTime.Now });

        conn.BeginTransaction();

        ArrayList tableList = new ArrayList();
        tableList.Add("SSO_Login");
        conn.TableLock(tableList);
        returnValue = conn.Update("SSO_Login", dt, "SSO_Guid='" + pSessionID + "'");
        conn.CommitTransaction();

        hzyMessage.ClearUserInfo();
        hzyMessage.Message = "登出成功";

        return returnValue;
    }
Пример #14
0
        /// <summary>
        /// 根据XML内容更新品牌
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "ISNULL(BD0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @" SELECT 
                                    [BD0_CONO]
                                   ,[BD0_DIVI]
                                   ,[BD0_BrandId]
                                   ,[BD0_BrandCode]
                                   ,[BD0_SU0_SupplierId]
                                   ,[BD0_BrandName]
                                   ,[BD0_CountryId]
                                   ,[BD0_StyleId]
                                   ,[BD0_CusGrpId]
                                   ,[BD0_Status]
                                   ,[BD0_RgUser]
                                   ,[BD0_RgDt]
                                   ,[BD0_LmUser]
                                   ,[BD0_LmDt]
                                   ,[BD0_UptNo]
                                   ,A.[SU0_SupplierCode] 
                                   ,B.[DC0_DictName1] AS CountryDictName
                                   ,C.[DC0_DictName1] AS StyleDictName
                                   ,D.[DC0_DictName1] AS CusGrpDictName
                                FROM   B01_MDM.BD0_Brand WITH ( NOLOCK )    
                                LEFT JOIN  B01_MDM.SU0_Supplier A ON  BD0_SU0_SupplierId=A.SU0_SupplierId   
                                LEFT JOIN  M01_CONF.DC0_Dictionary B ON  BD0_CountryId=B.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary C ON  BD0_StyleId=C.DC0_DictId 
                                LEFT JOIN  M01_CONF.DC0_Dictionary D ON  BD0_CusGrpId=D.DC0_DictId                                   
                                WHERE " + strWHERE
                                + @"ORDER BY [BD0_LmDt] DESC ";
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B01_MDM.BD0_Brand");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B01_MDM.BD0_Brand SET BD0_Status=1 
                               WHERE BD0_BrandId='" + ds.Tables["LIST"].Rows[i]["BD0_BrandId"].ToString() + @"'
                                AND ISNULL(BD0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B01_MDM.BD0_Brand WHERE  BD0_BrandId=@param0
                                AND ISNULL(BD0_Status,'') <>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["BD0_BrandId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    //处理结果
                                    if (ds.Tables["LIST"].Rows[i]["BD0_LmUser"].ToString() != "")
                                    {
                                        string strCode = dt_SR.Rows[0]["BD0_UptNo"].ToString();
                                        if (strCode == "0")
                                        {
                                            strCode = Convert.ToInt32(strCode) + 1.ToString();
                                        }
                                        else
                                        {
                                            strCode = "0";
                                        }

                                        if (!dt.Columns.Contains("BD0_LmDt"))
                                        {
                                            dt.Columns.Add("BD0_LmDt");
                                        }
                                     //   if (!dt.Columns.Contains("BD0_Status"))
                                      //  {
                                      //      dt.Columns.Add("BD0_Status");
                                      //  }

                                        if (!dt.Columns.Contains("BD0_UptNo"))
                                        {
                                            dt.Columns.Add("BD0_UptNo");
                                        }

                                      //  dt.Rows[0]["BD0_Status"] = '0';
                                        dt.Rows[0]["BD0_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["BD0_UptNo"] = strCode;
                                    }

                                    conn.Update("B01_MDM.BD0_Brand", dt, "BD0_BrandId='" + ds.Tables["LIST"].Rows[i]["BD0_BrandId"].ToString() + @"'");


                                }
 
                                else  //add
                                {

                                    strSQL = @"SELECT BD0_BrandCode FROM  B01_MDM.BD0_Brand  WHERE  BD0_BrandCode=@param0
                                                ";
                                    DataTable dt_SU = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["BD0_BrandCode"].ToString()});

                                    if (dt_SU.Rows.Count > 0)
                                    {
                                        string BD0_BrandCode = dt_SU.Rows[0]["BD0_BrandCode"].ToString();


                                     //   ITSM_Common.SendAMMessage("你输入的品牌编号已存在,最近添加的品牌编号是" + BD0_BrandCode);
                                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "你输入的品牌编号已存在,最近添加的品牌编号是" + BD0_BrandCode });
                                        conn.RollbackTransaction();
                                        return ds_Return;

                                        
                                    }
                                    else
                                    {
                                         string BD0_BrandId = Guid.NewGuid().ToString();


                                        if (!dt.Columns.Contains("BD0_BrandId"))
                                        {
                                            dt.Columns.Add("BD0_BrandId");
                                        }

                                 //   if (!dt.Columns.Contains("BD0_Status"))
                                 //   {
                                 //       dt.Columns.Add("BD0_Status");
                                 //   }

                                        if (!dt.Columns.Contains("BD0_RgDt"))
                                        {
                                            dt.Columns.Add("BD0_RgDt");
                                        }

                                        if (!dt.Columns.Contains("BD0_LmDt"))
                                        {
                                         dt.Columns.Add("BD0_LmDt");
                                        }

                                         if (!dt.Columns.Contains("BD0_UptNo"))
                                        {
                                         dt.Columns.Add("BD0_UptNo");
                                        }


                                        dt.Rows[0]["BD0_BrandId"] = BD0_BrandId;
                                //    dt.Rows[0]["BD0_Status"] = '0';
                                        dt.Rows[0]["BD0_RgDt"] = DateTime.Now;
                                        dt.Rows[0]["BD0_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["BD0_UptNo"] = '0';

                                 

                                        conn.Insert("B01_MDM.BD0_Brand", dt);
                                    }

                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
        public bool Execute()
        {

            Dbconn conn = new Dbconn("AM");
            DataSet ds = conn.GetDataSet(
                @"SELECT  DISTINCT t1.CN_S_EMITEM_ID AS AM_USER_ID ,
                            t1.CN_P_EMITEM_ID AS AM_S_Dept_ID  	
                    FROM     TN_SYS_EM_USER t2 WITH ( NOLOCK )
                            LEFT   JOIN  TN_SYS_EM_RELATION t1 WITH ( NOLOCK ) ON t1.CN_S_EMITEM_ID = t2.CN_ID
                    WHERE   1 = 1
                            AND t2.CN_ISDELETE = 0
                            AND t2.CN_DISABLED = 0
                            AND t1.CN_REL_TYPE = 1
                            AND CN_S_EMITEM_TYPE=0
                            AND ( 
                            ( CN_P_EMITEM_TYPE = 1
                                    AND EXISTS ( SELECT 1
                                                 FROM    TN_SYS_EM_GROUP t3 WITH ( NOLOCK )
                                                 WHERE  T1.CN_P_EMITEM_ID = T3.cn_id
                                                        AND T3.CN_OWNERID = 0 )
                                  )
                                  OR 
                                  ( CN_P_EMITEM_TYPE = 3
                                       AND EXISTS ( SELECT  1
                                                    FROM     TN_SYS_EM_VIEW T4 WITH ( NOLOCK )
                                                    WHERE   1 = 1
                                                            AND CN_VIEW_TYPE = 1
                                                            AND CN_OWNERID = 0
                                                            AND CN_P_EMITEM_ID = T4.cn_id )
                                     )
                                )
                     ");



            Dbconn connMDM = new Dbconn("MDM");

            try
            {


                ArrayList tableList = new ArrayList();
                connMDM.BeginTransaction();

                tableList.Add("Am_User_Dept_log");
                tableList.Add("Am_User_Dept");
                connMDM.TableLock(tableList);


//                //存入日志数据
//                connMDM.ExcuteQuerryByTran(@"INSERT  INTO dbo.Am_User_Dept_log
//                ( Log_datetime ,
//				  AM_USER_ID,
//                  AM_S_Dept_ID ,
//                  CreateTime ,
//                  UpdateTime,
//                  Timestamps_old
//		        
//                )
//                SELECT  GETDATE() ,
//						AM_USER_ID,
//                        AM_S_Dept_ID ,
//                        CreateTime ,
//                        UpdateTime,
//                        convert(bigint,Timestamps)
//                FROM    Am_User_Dept");


                //删除数据
                connMDM.ExcuteQuerryByTran("DELETE  FROM Am_User_Dept");
                connMDM.InsertBYSQLBC("Am_User_Dept", ds.Tables[0]);
                connMDM.CommitTransaction();
                return true;
            }
            catch
            {
                connMDM.RollbackTransaction();
                throw;
            }
        }
        /// <summary>
        /// 根据XML内容更新采购单明细
        /// </summary>
        /// <returns></returns>
        /// 
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                string strSQL1 = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @"  
                                      SELECT 
                                      [PR1D_CONO]
                                     ,[PR1D_DIVI]
                                     ,[PR1D_OrderDetailId]
                                     ,[PR1D_PR1_OrderId]
                                     ,[PR1D_PD0_ProductId]
                                     ,CAST([PR1D_Total] AS DECIMAL(20,0)) AS PR1D_Total
                                     ,[PR1D_UnitID]
                                     ,CAST([PR1D_POriginalPrice] AS DECIMAL(20,2)) as PR1D_POriginalPrice
                                     ,CAST([PR1D_PCurrencyPrice] AS DECIMAL(20,2)) as PR1D_PCurrencyPrice
                                     ,CAST([PR1D_SCurrencyPrice] AS DECIMAL(20,2)) as PR1D_SCurrencyPrice
                                     ,CAST([PR1D_Discount] AS DECIMAL(20,2)) as PR1D_Discount
                                     ,CAST([PR1D_EstimateCost] AS DECIMAL(20,2)) as PR1D_EstimateCost
                                     ,CAST([PR1D_OriginalAmount] AS DECIMAL(20,2)) as PR1D_OriginalAmount
                                     ,CAST([PR1D_CurrencyAmount] AS DECIMAL(20,2)) as  PR1D_CurrencyAmount
                                     ,[PR1D_Status]
                                     ,[PR1D_SendDate]
                                     ,[PR1D_Seq]
                                     ,[PR1D_RgUser]
                                     ,[PR1D_RgDt]
                                     ,[PR1D_LmUser]
                                     ,[PR1D_LmDt]
                                     ,[PR1D_UptNo]
                                     ,PR1D_CurrencyTypeId
                                     ,PD0_ColorId
                                     ,PD0_ColorSUId
                                     ,PD0_ColorBSUId
                                     ,PD0_SizeSUId
                                     ,A.PR1_OrderCode
                                     ,B.PD0_ProductCodeSU
                                     ,B.PD0_SKUSU as PR1D_PD0_SKUSU
                                     ,B.PD0_SKU as PR1D_PD0_SKU
                                     ,C.SU0_SupplierCode
                                     ,C.SU0_SupplierType
                                     ,D.DC0_DictName1 AS UnitDictName
                                     ,E.DC0_DictName1 AS StatusDictName
                                     ,H.DC0_DictName1 AS CurrencyTypeDictName
                                     ,I.DC0_DictName1 AS  ColorTypeDictName

                                     FROM B02_Bill.PR1D_OrderDetail
                                     LEFT JOIN B02_Bill.PR1_Order A        ON  A.PR1_OrderId=PR1D_PR1_OrderId
                                     LEFT JOIN B01_MDM.PD0_Product B       ON  B.PD0_ProductId=PR1D_PD0_ProductId
                                     LEFT JOIN  B01_MDM.SU0_Supplier C     ON  PR1_SU0_SupplierId=C.SU0_SupplierId
                                     LEFT JOIN  M01_CONF.DC0_Dictionary  D ON  PR1D_UnitID=D.DC0_DictId  
                                     LEFT JOIN  M01_CONF.DC0_Dictionary  E ON  PR1D_Status=E.DC0_DictId  
                                     LEFT JOIN  M01_CONF.DC0_Dictionary  F ON  B.PD0_SKUSU=F.DC0_DictId  
                                     LEFT JOIN  M01_CONF.DC0_Dictionary  G ON  B.PD0_Code=G.DC0_DictId  
                                     LEFT JOIN  M01_CONF.DC0_Dictionary  H ON  PR1D_CurrencyTypeId=H.DC0_DictId 
                                     LEFT JOIN  M01_CONF.DC0_Dictionary  I ON  B.PD0_ColorId=H.DC0_DictId 
                                WHERE " + strWHERE
                                        + @"ORDER BY [PR1D_LmDt] DESC "; 
                            // ,PD0_SizeSUId
                          // ,I.DC0_DictName2 AS ColorBSUIdDictName
                          //   ,I.DC0_DictName1 AS ColorSUIdDictName
                         //   ,K.DC0_DictName1 AS SizeSUIdTypeDictName

                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B02_Bill.PR1D_OrderDetail");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B02_Bill.PR1D_OrderDetail SET PR1D_Status='E3CA9B7A-8E17-4E52-B667-39689445D4A1' 
                               WHERE PR1D_OrderDetailId='" + ds.Tables["LIST"].Rows[i]["PR1D_OrderDetailId"].ToString() + @"'
                               AND isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                               ";                           
                                conn.ExcuteQuerryByTran(strSQL);

                                strSQL = @"SELECT * FROM B02_Bill.PR1D_OrderDetail  WHERE  PR1D_PR1_OrderId=@param0
                                AND isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                ";
                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    strSQL = @"UPDATE AA SET AA.PR1_PurchaseTotal=BB.PR1_PurchaseTotal,
                                               AA.PR1_PurchaseAmount=BB.PR1_PurchaseAmount,AA.PR1_POriginalAmount=BB.PR1_POriginalAmount,
                                               AA.PR1_LmUser='******',
                                               AA.PR1_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                               AA.PR1_UptNo=AA.PR1_UptNo+1
                                               FROM 
                                               B02_Bill.PR1_Order AA,
                                               (SELECT SUM(PR1D_Total) AS PR1_PurchaseTotal,SUM(PR1D_OriginalAmount) AS PR1_POriginalAmount,
                                                SUM(PR1D_EstimateCost) AS PR1D_EstimateCost,SUM(PR1D_CurrencyAmount) AS PR1_PurchaseAmount,PR1D_PR1_OrderId
                                                FROM B02_Bill.PR1D_OrderDetail WHERE PR1D_PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                                 AND isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                                GROUP BY PR1D_PR1_OrderId)BB
                                                WHERE AA.PR1_OrderId=BB.PR1D_PR1_OrderId";
                                    conn.ExcuteQuerryByTran(strSQL);

                                }
                                else
                                {
                                    strSQL = @"UPDATE AA SET AA.PR1_PurchaseTotal='0',
                                               AA.PR1_PurchaseAmount='0',AA.PR1_POriginalAmount='0',
                                               AA.PR1_LmUser='******',
                                               AA.PR1_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                               AA.PR1_UptNo=AA.PR1_UptNo+1
                                               FROM 
                                               B02_Bill.PR1_Order AA
                                                WHERE AA.PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'";
                                    conn.ExcuteQuerryByTran(strSQL);
                                }
 

                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B02_Bill.PR1D_OrderDetail  WHERE  PR1D_OrderDetailId=@param0
                                AND isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PR1D_OrderDetailId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {


                                    strSQL = @"SELECT * FROM B01_MDM.PD0_Product  WHERE  PD0_ProductId=@param0
                                            AND  PD0_SKUSU=@param1   AND isnull(PD0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                             ";

                                 DataTable dt_SU = conn.GetDataTable(strSQL, new string[2] { ds.Tables["LIST"].Rows[i]["PR1D_PD0_ProductId"].ToString(), ds.Tables["LIST"].Rows[i]["PR1D_PD0_SKUSU"].ToString() });
                                //update
                                if (dt_SU.Rows.Count > 0)
                                {

                                    //处理结果
                                  //  if (ds.Tables["LIST"].Rows[i]["PR1D_LmUser"].ToString() != "")
                                  //  {

                                        DataTable dtTemp = conn.GetDataTableInTrans(
                                         @" SELECT CC.PR1D_CurrencyAmount,CC.PR1D_POriginalPrice,CC.PR1D_OriginalAmount,CC.PR1D_EstimateCost,CC.PR1D_PCurrencyPrice,
                                       case when cast(right(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1),2)as int)<30 and '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国外'
                                        then CAST(SUBSTRING(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',CC.PR1D_SCurrencyPrice)-1),1,len(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1))-2)-1 AS VARCHAR(20))+'99'
                                        when cast(right(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1),2)as int)>=30 and '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国外'
                                        then SUBSTRING(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1),1,len(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1))-2)+'99'
                                        when '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国内' then '0'
                                        END  AS PR1D_SCurrencyPrice  FROM
                                       (SELECT AA.PR1D_CurrencyAmount as PR1D_CurrencyAmount,AA.PR1D_POriginalPrice,AA.PR1D_OriginalAmount as PR1D_OriginalAmount,AA.PR1D_EstimateCost as PR1D_EstimateCost,
                                       CASE WHEN '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国内' THEN '0'
                                       ELSE AA.PR1D_EstimateCost/" + ds.Tables["LIST"].Rows[i]["PR1D_Discount"].ToString() + @" END AS PR1D_SCurrencyPrice,AA.PR1D_PCurrencyPrice as PR1D_PCurrencyPrice
                                       FROM 
                                      (select PR1_OrderId," + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @" as PR1D_POriginalPrice  ," + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate AS PR1D_PCurrencyPrice,
                                       CASE WHEN '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国内' THEN " + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate 
                                       ELSE " + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate*(1+PR1_Tariff)*(1+PR1_VAT)*(1+PR1_Freight)
                                       END AS PR1D_EstimateCost," + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*" + ds.Tables["LIST"].Rows[i]["PR1D_Total"].ToString() + @" AS PR1D_OriginalAmount,
                                       " + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate*" + ds.Tables["LIST"].Rows[i]["PR1D_Total"].ToString() + @" AS PR1D_CurrencyAmount
                                       FROM B02_Bill.PR1_Order
                                       WHERE PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                        AND ISNULL(PR1_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1')AA,
                                        B02_Bill.PR1_Order BB WHERE AA.PR1_OrderId=BB.PR1_OrderId)CC
                                      ");


                                        string PR1D_CurrencyAmount = dtTemp.Rows[0]["PR1D_CurrencyAmount"].ToString();
                                        string PR1D_PCurrencyPrice = dtTemp.Rows[0]["PR1D_PCurrencyPrice"].ToString();
                                        string PR1D_OriginalAmount = dtTemp.Rows[0]["PR1D_OriginalAmount"].ToString();
                                        string PR1D_EstimateCost = dtTemp.Rows[0]["PR1D_EstimateCost"].ToString();
                                        string PR1D_SCurrencyPrice = dtTemp.Rows[0]["PR1D_SCurrencyPrice"].ToString();
                                        string PR1D_POriginalPrice = dtTemp.Rows[0]["PR1D_POriginalPrice"].ToString();

                                        if (PR1D_SCurrencyPrice == "0")
                                        {
                                            PR1D_SCurrencyPrice = ds.Tables["LIST"].Rows[i]["PR1D_SCurrencyPrice"].ToString();
                                        }

                                        string strCode = dt_SR.Rows[0]["PR1D_UptNo"].ToString();
                                        if (strCode == "0")
                                        {
                                            strCode = Convert.ToInt32(strCode) + 1.ToString();
                                        }
                                        else
                                        {
                                            strCode = "0";
                                        }


                            


                                        if (!dt.Columns.Contains("PR1D_LmDt"))
                                        {
                                            dt.Columns.Add("PR1D_LmDt");
                                        }

                                        if (!dt.Columns.Contains("PR1D_CurrencyAmount"))
                                        {
                                            dt.Columns.Add("PR1D_CurrencyAmount");
                                        }

                                        if (!dt.Columns.Contains("PR1D_PCurrencyPrice"))
                                        {
                                            dt.Columns.Add("PR1D_PCurrencyPrice");
                                        }

                                        if (!dt.Columns.Contains("PR1D_OriginalAmount"))
                                        {
                                            dt.Columns.Add("PR1D_OriginalAmount");
                                        }

                                        if (!dt.Columns.Contains("PR1D_EstimateCost"))
                                        {
                                            dt.Columns.Add("PR1D_EstimateCost");
                                        }

                                        if (!dt.Columns.Contains("PR1D_POriginalPrice"))
                                        {
                                            dt.Columns.Add("PR1D_POriginalPrice");
                                        }

                                        if (!dt.Columns.Contains("PR1D_SCurrencyPrice"))
                                        {
                                            dt.Columns.Add("PR1D_SCurrencyPrice");
                                        }


                                        if (!dt.Columns.Contains("PR1D_UptNo"))
                                        {
                                            dt.Columns.Add("PR1D_UptNo");
                                        }

                                        dt.Rows[0]["PR1D_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["PR1D_CurrencyAmount"] = PR1D_CurrencyAmount;
                                        dt.Rows[0]["PR1D_PCurrencyPrice"] = PR1D_PCurrencyPrice;
                                        dt.Rows[0]["PR1D_OriginalAmount"] = PR1D_OriginalAmount;
                                        dt.Rows[0]["PR1D_EstimateCost"] = PR1D_EstimateCost;
                                        dt.Rows[0]["PR1D_SCurrencyPrice"] = PR1D_SCurrencyPrice;
                                        dt.Rows[0]["PR1D_POriginalPrice"] = PR1D_POriginalPrice;
                                        dt.Rows[0]["PR1D_UptNo"] = strCode;

 

                                    
                                    dt.Columns.Remove("PR1D_SupplierType");
                                    dt.Columns.Remove("PR1D_PD0_SKUSU");
                                    conn.Update("B02_Bill.PR1D_OrderDetail", dt, "PR1D_OrderDetailId='" + ds.Tables["LIST"].Rows[i]["PR1D_OrderDetailId"].ToString() + @"'");

                                    strSQL = @"UPDATE AA SET AA.PR1_PurchaseTotal=BB.PR1_PurchaseTotal,
                                               AA.PR1_PurchaseAmount=BB.PR1_PurchaseAmount,AA.PR1_POriginalAmount=BB.PR1_POriginalAmount,
                                               AA.PR1_LmUser='******',
                                               AA.PR1_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                               AA.PR1_UptNo=AA.PR1_UptNo+1
                                               FROM 
                                               B02_Bill.PR1_Order AA,
                                               (SELECT SUM(PR1D_Total) AS PR1_PurchaseTotal,SUM(PR1D_OriginalAmount) AS PR1_POriginalAmount,
                                                SUM(PR1D_EstimateCost) AS PR1D_EstimateCost,SUM(PR1D_CurrencyAmount) AS PR1_PurchaseAmount,PR1D_PR1_OrderId
                                                FROM B02_Bill.PR1D_OrderDetail WHERE PR1D_PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                                 AND isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                                GROUP BY PR1D_PR1_OrderId)BB
                                                WHERE AA.PR1_OrderId=BB.PR1D_PR1_OrderId";
                                    conn.ExcuteQuerryByTran(strSQL);

                                    strSQL = @"UPDATE B01_MDM.PD0_Product SET PD0_PurchasePrice='" + PR1D_CurrencyAmount + @"',
                                               PD0_SalePrice='" + PR1D_SCurrencyPrice + @"',
                                               PD0_LmUser='******',
                                               PD0_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                               PD0_UptNo=PD0_UptNo+1
                                               WHERE PD0_ProductId='" + ds.Tables["LIST"].Rows[i]["PR1D_PD0_ProductId"].ToString() + @"'                "
                                               ;
                                    strSQL1 = @"UPDATE  A  SET A.PR0_Amount=B.PR1_POriginalAmount,A.PR0_Total=PR1_PurchaseTotal
                                                FROM B02_Bill.PR0_Contract A,
                                                    (select SUM(PR1_POriginalAmount) as   PR1_POriginalAmount,PR1_PR0_ContractId,SUM(PR1_PurchaseTotal) as   PR1_PurchaseTotal 
                                                     from B02_Bill.PR1_Order   
                                                     WHERE  PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                                    AND ISNULL(PR1_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' 
                                                     GROUP BY PR1_PR0_ContractId)B
                                                     WHERE A.PR0_ContractId=B.PR1_PR0_ContractId "
                                                    ;
                                    conn.ExcuteQuerryByTran(strSQL1);


                                   }
                                }
                                     
                                else  //add
                                {
                                    strSQL = @"SELECT * FROM B01_MDM.PD0_Product  WHERE  PD0_ProductId=@param0
                                               AND  PD0_SKUSU=@param1
                                             ";

                                    DataTable dt_SU = conn.GetDataTable(strSQL, new string[2] { ds.Tables["LIST"].Rows[i]["PR1D_PD0_ProductId"].ToString(), ds.Tables["LIST"].Rows[i]["PR1D_PD0_SKUSU"].ToString() });
                                //update
                                if (dt_SU.Rows.Count > 0)
                                {


                                    DataTable dtTemp = conn.GetDataTableInTrans(
                                    @"
                                        SELECT CC.PR1D_CurrencyAmount,CC.PR1D_POriginalPrice,CC.PR1D_OriginalAmount,CC.PR1D_EstimateCost,CC.PR1D_PCurrencyPrice,
                                        case when cast(right(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1),2)as int)<30 and '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国外'
                                        then CAST(SUBSTRING(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',CC.PR1D_SCurrencyPrice)-1),1,len(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1))-2)-1 AS VARCHAR(20))+'99'
                                        when cast(right(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1),2)as int)>=30 and '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国外'
                                        then SUBSTRING(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1),1,len(SUBSTRING(cast(CC.PR1D_SCurrencyPrice as varchar(20)),1,charindex('.',cast(CC.PR1D_SCurrencyPrice as varchar(20)))-1))-2)+'99'
                                        when '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国内' then '0'
                                        END  AS PR1D_SCurrencyPrice  FROM
                                       (SELECT AA.PR1D_CurrencyAmount as PR1D_CurrencyAmount,AA.PR1D_POriginalPrice,AA.PR1D_OriginalAmount as PR1D_OriginalAmount,AA.PR1D_EstimateCost as PR1D_EstimateCost,
                                       CASE WHEN '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国内' THEN '0'
                                       ELSE AA.PR1D_EstimateCost/" + ds.Tables["LIST"].Rows[i]["PR1D_Discount"].ToString() + @" END AS PR1D_SCurrencyPrice,AA.PR1D_PCurrencyPrice as PR1D_PCurrencyPrice
                                       FROM 
                                      (select PR1_OrderId," + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @" as PR1D_POriginalPrice  ," + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate AS PR1D_PCurrencyPrice,
                                       CASE WHEN '" + ds.Tables["LIST"].Rows[i]["PR1D_SupplierType"].ToString() + @"'='国内' THEN " + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate 
                                       ELSE " + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate*(1+PR1_Tariff)*(1+PR1_VAT)*(1+PR1_Freight)
                                       END AS PR1D_EstimateCost," + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*" + ds.Tables["LIST"].Rows[i]["PR1D_Total"].ToString() + @" AS PR1D_OriginalAmount,
                                       " + ds.Tables["LIST"].Rows[i]["PR1D_POriginalPrice"].ToString() + @"*PR1_ExchangeRate*" + ds.Tables["LIST"].Rows[i]["PR1D_Total"].ToString() + @" AS PR1D_CurrencyAmount
                                       FROM B02_Bill.PR1_Order
                                       WHERE PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                        AND ISNULL(PR1_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1')AA,
                                        B02_Bill.PR1_Order BB WHERE AA.PR1_OrderId=BB.PR1_OrderId)CC
                                      ");


                                    string PR1D_CurrencyAmount = dtTemp.Rows[0]["PR1D_CurrencyAmount"].ToString();
                                    string PR1D_PCurrencyPrice = dtTemp.Rows[0]["PR1D_PCurrencyPrice"].ToString();
                                    string PR1D_OriginalAmount = dtTemp.Rows[0]["PR1D_OriginalAmount"].ToString();
                                    string PR1D_EstimateCost = dtTemp.Rows[0]["PR1D_EstimateCost"].ToString();
                                    string PR1D_SCurrencyPrice = dtTemp.Rows[0]["PR1D_SCurrencyPrice"].ToString();
                                    string PR1D_POriginalPrice = dtTemp.Rows[0]["PR1D_POriginalPrice"].ToString();

                                    if (PR1D_SCurrencyPrice == "0")
                                    {
                                        PR1D_SCurrencyPrice = ds.Tables["LIST"].Rows[i]["PR1D_SCurrencyPrice"].ToString();
                                    }

                                    string PR1D_OrderDetailId = Guid.NewGuid().ToString();


                                    if (!dt.Columns.Contains("PR1D_OrderDetailId"))
                                    {
                                        dt.Columns.Add("PR1D_OrderDetailId");
                                    }

                                    if (!dt.Columns.Contains("PR1D_RgDt"))
                                    {
                                        dt.Columns.Add("PR1D_RgDt");
                                    }

                                    if (!dt.Columns.Contains("PR1D_LmDt"))
                                    {
                                        dt.Columns.Add("PR1D_LmDt");
                                    }

                                    if (!dt.Columns.Contains("PR1D_UptNo"))
                                    {
                                        dt.Columns.Add("PR1D_UptNo");
                                    }

                                    if (!dt.Columns.Contains("PR1D_CurrencyAmount"))
                                    {
                                        dt.Columns.Add("PR1D_CurrencyAmount");
                                    }

                                    if (!dt.Columns.Contains("PR1D_PCurrencyPrice"))
                                    {
                                        dt.Columns.Add("PR1D_PCurrencyPrice");
                                    }

                                    if (!dt.Columns.Contains("PR1D_OriginalAmount"))
                                    {
                                        dt.Columns.Add("PR1D_OriginalAmount");
                                    }

                                    if (!dt.Columns.Contains("PR1D_EstimateCost"))
                                    {
                                        dt.Columns.Add("PR1D_EstimateCost");
                                    }

                                    if (!dt.Columns.Contains("PR1D_SCurrencyPrice"))
                                    {
                                        dt.Columns.Add("PR1D_SCurrencyPrice");
                                    }





                                    dt.Rows[0]["PR1D_OrderDetailId"] = PR1D_OrderDetailId;
                                    dt.Rows[0]["PR1D_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["PR1D_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["PR1D_UptNo"] = '0';
                                    dt.Rows[0]["PR1D_CurrencyAmount"] = PR1D_CurrencyAmount;
                                    dt.Rows[0]["PR1D_PCurrencyPrice"] = PR1D_PCurrencyPrice;
                                    dt.Rows[0]["PR1D_OriginalAmount"] = PR1D_OriginalAmount;
                                    dt.Rows[0]["PR1D_EstimateCost"] = PR1D_EstimateCost;
                                    dt.Rows[0]["PR1D_SCurrencyPrice"] = PR1D_SCurrencyPrice;
                                    dt.Rows[0]["PR1D_POriginalPrice"] = PR1D_POriginalPrice;

                                    dt.Columns.Remove("PR1D_SupplierType");
                                    dt.Columns.Remove("PR1D_PD0_SKUSU");
                                    conn.Insert("B02_Bill.PR1D_OrderDetail", dt);



                                    strSQL = @"UPDATE AA SET AA.PR1_PurchaseTotal=BB.PR1_PurchaseTotal,
                                               AA.PR1_PurchaseAmount=BB.PR1_PurchaseAmount,AA.PR1_POriginalAmount=BB.PR1_POriginalAmount,
                                               AA.PR1_LmUser='******',
                                               AA.PR1_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                               AA.PR1_UptNo=AA.PR1_UptNo+1
                                               FROM 
                                               B02_Bill.PR1_Order AA, 
                                               (SELECT SUM(PR1D_Total) AS PR1_PurchaseTotal,SUM(PR1D_OriginalAmount) AS PR1_POriginalAmount,
                                                SUM(PR1D_EstimateCost) AS PR1D_EstimateCost,SUM(PR1D_CurrencyAmount) AS PR1_PurchaseAmount,PR1D_PR1_OrderId
                                                FROM B02_Bill.PR1D_OrderDetail WHERE PR1D_PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                                AND isnull(PR1D_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'                                         
                                                GROUP BY PR1D_PR1_OrderId)BB
                                                WHERE AA.PR1_OrderId=BB.PR1D_PR1_OrderId";

                                    conn.ExcuteQuerryByTran(strSQL);

                                    strSQL1 = @"UPDATE B01_MDM.PD0_Product SET PD0_PurchasePrice='" + PR1D_CurrencyAmount + @"',
                                               PD0_SalePrice='" + PR1D_SCurrencyPrice + @"',
                                               PD0_LmUser='******',
                                               PD0_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                               PD0_UptNo=PD0_UptNo+1
                                               WHERE PD0_ProductId='" + ds.Tables["LIST"].Rows[i]["PR1D_PD0_ProductId"].ToString() + @"'                "
                                               ;
                                    conn.ExcuteQuerryByTran(strSQL1);


                                    strSQL1 = @"UPDATE  A  SET A.PR0_Amount=B.PR1_POriginalAmount,A.PR0_Total=PR1_PurchaseTotal
                                                FROM B02_Bill.PR0_Contract A,
                                                    (select SUM(PR1_POriginalAmount) as   PR1_POriginalAmount,PR1_PR0_ContractId,SUM(PR1_PurchaseTotal) as   PR1_PurchaseTotal 
                                                     from B02_Bill.PR1_Order   
                                                     WHERE  PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                                        AND ISNULL(PR1_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'                                            
                                                        GROUP BY PR1_PR0_ContractId)B
                                                     WHERE A.PR0_ContractId=B.PR1_PR0_ContractId "
                                                    ;
                                     conn.ExcuteQuerryByTran(strSQL1) ;
                                     
                                     

                                    }

                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
Пример #17
0
        /// <summary>
        /// 根据XML内容更新供应商
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "ISNULL(PD0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";

                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }
                    strSQL = @" 
                                      SELECT  
                                     [PD0_CONO]
                                    ,[PD0_DIVI]
                                    ,[PD0_ProductId]
                                    ,[PD0_SUO_SupplierId]
                                    ,[PD0_BD0_BrandId]
                                    ,[PD0_ProductCodeSU]
                                    ,[PD0_ColorSUId]
                                    ,[PD0_SizeSUId]
                                    ,[PD0_SKUSU]
                                    ,[PD0_Code]
                                    ,[PD0_ColorId]
                                    ,[PD0_SizeId]
                                    ,[PD0_SKU]
                                    ,[PD0_YearId]
                                    ,[PD0_SeasonId]
                                    ,[PD0_Lvl1]
                                    ,[PD0_Lvl2] 
                                    ,[PD0_Lvl3]
                                    ,[PD0_SourceCountry]
                                    ,[PD0_Composition]
                                    ,[PD0_QulityLevel]
                                    ,[PD0_StandardId]
                                    ,[PD0_SecurityLevelId]
                                    ,cast([PD0_PurchasePrice] as decimal(20,2)) as PD0_PurchasePrice
                                    ,cast([PD0_SalePrice] as decimal(20,2)) as PD0_SalePrice  
                                    ,[PD0_UnitId]
                                    ,[PD0_IsPrinted]
                                    ,[PD0_Status]
                                    ,[PD0_RgUser]
                                    ,[PD0_RgDt]
                                    ,[PD0_LmUser]
                                    ,[PD0_LmDt]
                                    ,[PD0_ColorSUId]
                                    ,[PD0_PicPath]
                                    ,[PD0_Lvl0]
                                    ,A.[SU0_SupplierCode] 
                                    ,B.[BD0_BrandName]  
                                    ,C.[DC0_DictName1] AS YearDictName
                                    ,D.[DC0_DictName1] AS SeasonDictName
                                    ,E.[DC0_DictName1] AS StandardDictName
                                    ,F.[DC0_DictName1] AS SecurityLevelDictName
                                    ,G.[DC0_DictName1] AS ColorSUDictName
                                    ,H.[DC0_DictName1] AS SizeSUDictName
                                    ,I.[DC0_DictName1] AS Lvl1DictName
                                    ,J.[DC0_DictName1] AS Lvl2DictName
                                    ,K.[DC0_DictName1] AS ColorBSUName
  
                                    ,M.[DC0_DictName1] AS ColorDictName
                                    ,N.[DC0_DictName1] AS SizeDictName
                                FROM   B01_MDM.PD0_Product WITH ( NOLOCK )    
                                LEFT JOIN  B01_MDM.SU0_Supplier    A ON  PD0_SUO_SupplierId=A.SU0_SupplierId
                                LEFT JOIN  B01_MDM.BD0_Brand       B ON  PD0_BD0_BrandId=B.BD0_BrandId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary C ON  PD0_YearId=C.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary D ON  PD0_SeasonId=D.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary E ON  PD0_StandardId=E.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary F ON  PD0_SecurityLevelId=F.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary G ON  PD0_ColorSUId=G.DC0_DictId  
                                LEFT JOIN  M01_CONF.DC0_Dictionary H ON  PD0_SizeSUId=H.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary I ON  PD0_Lvl1=I.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary J ON  PD0_Lvl2=J.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary K ON  PD0_ColorSUId=K.DC0_DictId
 
                                LEFT JOIN  M01_CONF.DC0_Dictionary M ON  PD0_ColorId=M.DC0_DictId
                                LEFT JOIN  M01_CONF.DC0_Dictionary N ON  PD0_SizeId=N.DC0_DictId

                                WHERE " + strWHERE
                                      + @"ORDER BY [PD0_LmDt] DESC "; 
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B01_MDM.PD0_Product");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B01_MDM.PD0_Product SET PD0_Status='E3CA9B7A-8E17-4E52-B667-39689445D4A1' 
                               WHERE PD0_ProductId='" + ds.Tables["LIST"].Rows[i]["PD0_ProductId"].ToString() + @"'
                                AND ISNULL(PD0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B01_MDM.PD0_Product WHERE  PD0_ProductId=@param0
                                AND ISNULL(PD0_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PD0_ProductId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    //处理结果
                                    if (ds.Tables["LIST"].Rows[i]["PD0_LmUser"].ToString() != "")
                                    {
                                        string strCode = dt_SR.Rows[0]["PD0_UptNo"].ToString();
                                        if (strCode == "0")
                                        {
                                            strCode = Convert.ToInt32(strCode) + 1.ToString();
                                        }
                                        else
                                        {
                                            strCode = "0";
                                        }

                                        if (!dt.Columns.Contains("PD0_LmDt"))
                                        {
                                            dt.Columns.Add("PD0_LmDt");
                                        }
                                      //  if (!dt.Columns.Contains("PD0_Status"))
                                      //  {
                                      //      dt.Columns.Add("PD0_Status");
                                      //  }

                                        if (!dt.Columns.Contains("PD0_UptNo"))
                                        {
                                            dt.Columns.Add("PD0_UptNo");
                                        }

                                       // dt.Rows[0]["PD0_Status"] = '0';
                                        dt.Rows[0]["PD0_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["PD0_UptNo"] = strCode;
                                    }

                                    conn.Update("B01_MDM.PD0_Product", dt, "PD0_ProductId='" + ds.Tables["LIST"].Rows[i]["PD0_ProductId"].ToString() + @"'");


                                }
                                else  //add
                                {


                                 //   string PD0_ProductId = Guid.NewGuid().ToString();


                               //     if (!dt.Columns.Contains("PD0_ProductId"))
                               //     {
                               //         dt.Columns.Add("PD0_ProductId");
                                //    }

                                   // if (!dt.Columns.Contains("PD0_Status"))
                                   // {
                                  //      dt.Columns.Add("PD0_Status");
                                  //  }

                                    if (!dt.Columns.Contains("PD0_RgDt"))
                                    {
                                        dt.Columns.Add("PD0_RgDt");
                                    }

                                    if (!dt.Columns.Contains("PD0_LmDt"))
                                    {
                                        dt.Columns.Add("PD0_LmDt");
                                    }

                                    if (!dt.Columns.Contains("PD0_UptNo"))
                                    {
                                        dt.Columns.Add("PD0_UptNo");
                                    }


                                //    dt.Rows[0]["PD0_ProductId"] = PD0_ProductId;
                                  //  dt.Rows[0]["PD0_Status"] = '0';
                                    dt.Rows[0]["PD0_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["PD0_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["PD0_UptNo"] = '0';
                             
                                    conn.Insert("B01_MDM.PD0_Product", dt);

                          


                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
Пример #18
0
        /// <summary>
        /// 编辑任务参数信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("MDM");    //创建连接类

            try
            {
                if (m_request == null
                    || m_request.Tables.Count == 0
                    || m_request.Tables[0].Rows.Count == 0)
                {
                    return true;
                }
                string strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString();  //获取参数Task_ID
                string strParam_Name = m_request.Tables[0].Rows[0]["param_name"].ToString();  //获取参数Param_Name
                string strParam_ID = m_request.Tables[0].Rows[0]["param_id"].ToString();  //获取参数Param_ID

                ArrayList listTable = new ArrayList();
                listTable.Add("WS_SchedulingParam");
                conn.BeginTransaction();    //开启事务
                conn.TableLock(listTable);  //锁表WS_SchedulingParam
                string strWhere = " 1=1 ";

                if (!string.IsNullOrEmpty(strTASK_ID))
                {
                    strWhere += " AND TASK_ID = '" + strTASK_ID + "'";
                }

                if (!string.IsNullOrEmpty(strParam_Name))
                {
                    strWhere += " AND Param_Name = '" + strParam_Name + "'";
                }

                //创建DataTable
                DataTable dt_Add = new DataTable();
                dt_Add.Columns.Add("Param_ID");
                dt_Add.Columns.Add("TASK_ID");
                dt_Add.Columns.Add("Param_Name");
                dt_Add.Columns.Add("Param_Value");

                DataRow dr = dt_Add.NewRow();

                for (int i = 0; i < dt_Add.Columns.Count; i++)
                {
                    dr[i] = m_request.Tables[0].Rows[0][dt_Add.Columns[i].ColumnName].ToString();   //将m_request中的数据逐个赋值
                }
                dt_Add.Rows.Add(dr);



                if (strParam_ID == "") //如果为空,说明是复制数据
                {
                    //判断是否已经存在
                    int nRow = conn.GetDataTableRowCount("SELECT * FROM WS_SchedulingParam WHERE " + strWhere, new string[0]);
                    if (nRow > 0)
                    {
                        throw new Exception(strParam_Name + "已经存在,不能更新");
                    }
                    strParam_ID = Guid.NewGuid().ToString();    //创建GUID

                    dt_Add.Rows[0]["Param_ID"] = strParam_ID;
                    conn.Insert("WS_SchedulingParam", dt_Add);  //插入数据
                }
                else
                {
                    dt_Add.Columns.Remove("Param_ID");  //删除Param_ID,更新不需要
                    dt_Add.Columns.Remove("Task_ID");  //删除Task_ID,更新不需要
                    strWhere = " 1=1 AND Param_ID = '" + strParam_ID + "'"; //重新设置where语句
                    conn.Update("WS_SchedulingParam", dt_Add, strWhere);    //更新数据
                }
                //更新主表
                DataTable dtScheduling = new DataTable();
                dtScheduling.Columns.Add("UpdateTime");
                DataRow drScheduling = dtScheduling.NewRow();
                drScheduling["UpdateTime"] = DateTime.Now;
                dtScheduling.Rows.Add(drScheduling);
                string  strSchedulingWhere=" 1=1 AND TASK_ID = '" + strTASK_ID + "'";
                conn.Update("WS_Scheduling", dtScheduling, strSchedulingWhere);    //更新数据

                conn.CommitTransaction();
                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }
        }
        /// <summary>
        /// 根据XML内容更新审批流模版
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "1=1";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @" SELECT 
                                       [WFT_CONO]
                                      ,[WFT_DIVI]
                                      ,[WFT_AFDId]
                                      ,[WFT_Type]
                                      ,[WFT_Node]
                                      ,[WFT_Person]
                                      ,[WFT_Step]
                                      ,[WFT_IsMust]
                                      ,[WFT_RgUser]
                                      ,[WFT_RgDt]
                                      ,[WFT_LmUser]
                                      ,[WFT_LmDt]
                                      ,[WFT_UptNo]
                                FROM    GL_ERP.M02_BPM.WFT_AuditFlowDefine WITH ( NOLOCK )                                                
                                WHERE " + strWHERE;
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("GL_ERP.M02_BPM.WFT_AuditFlowDefine");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"DELETE FROM GL_ERP.M02_BPM.WFT_AuditFlowDefine  
                                WHERE WFT_AFDId='" + ds.Tables["LIST"].Rows[i]["WFT_AFDId"].ToString() + @"'
                                  ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM GL_ERP.M02_BPM.WFT_AuditFlowDefine WHERE  WFT_AFDId=@param0
                                 ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["WFT_AFDId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    //处理结果
                                    if (ds.Tables["LIST"].Rows[i]["WFT_LmUser"].ToString() != "")
                                    {
                                        string strCode = dt_SR.Rows[0]["WFT_UptNo"].ToString();
                                        if (strCode == "0")
                                        {
                                            strCode = Convert.ToInt32(strCode) + 1.ToString();
                                        }
                                        else
                                        {
                                            strCode = "0";
                                        }

                                        if (!dt.Columns.Contains("WFT_LmDt"))
                                        {
                                            dt.Columns.Add("WFT_LmDt");
                                        }


                                        if (!dt.Columns.Contains("WFT_UptNo"))
                                        {
                                            dt.Columns.Add("WFT_UptNo");
                                        }


                                        dt.Rows[0]["WFT_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["WFT_UptNo"] = strCode;
                                    }

                                    conn.Update("GL_ERP.M02_BPM.WFT_AuditFlowDefine", dt, "WFT_AFDId='" + ds.Tables["LIST"].Rows[i]["WFT_AFDId"].ToString() + @"'");


                                }

                                else  //add
                                {

                                    string WFT_AFDId = Guid.NewGuid().ToString();


                                    if (!dt.Columns.Contains("WFT_AFDId"))
                                    {
                                        dt.Columns.Add("WFT_AFDId");
                                    }


                                    if (!dt.Columns.Contains("WFT_RgDt"))
                                    {
                                        dt.Columns.Add("WFT_RgDt");
                                    }

                                    if (!dt.Columns.Contains("WFT_LmDt"))
                                    {
                                        dt.Columns.Add("WFT_LmDt");
                                    }

                                    if (!dt.Columns.Contains("WFT_UptNo"))
                                    {
                                        dt.Columns.Add("WFT_UptNo");
                                    }


                                    dt.Rows[0]["WFT_AFDId"] = WFT_AFDId;
                                    dt.Rows[0]["WFT_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["WFT_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["WFT_UptNo"] = '0';



                                    conn.Insert("GL_ERP.M02_BPM.WFT_AuditFlowDefine", dt);


                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
Пример #20
0
        /// <summary>
        /// 编辑任务信息
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("WSRR");

            try
            {
                if (m_request == null
                    || m_request.Tables.Count == 0
                    || m_request.Tables[0].Rows.Count == 0)
                {
                    return true;
                }
                string strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString();  //获取参数TaskID
                string strWS_Name = m_request.Tables[0].Rows[0]["ws_name"].ToString();  //获取参数WS名称

                ArrayList listTable = new ArrayList();
                listTable.Add("WS_Scheduling");
                conn.BeginTransaction();    //开启事务
                conn.TableLock(listTable);  //锁表WS_Scheduling
                string strWhere = string.Empty;

                //创建DataTable,用于传参
                DataTable dt_Add = new DataTable();
                dt_Add.Columns.Add("TASK_ID");
                dt_Add.Columns.Add("WS_ID");
                dt_Add.Columns.Add("URL");
                dt_Add.Columns.Add("WS_Name");
                dt_Add.Columns.Add("WS_LogicName");
                dt_Add.Columns.Add("Execute_Type");
                dt_Add.Columns.Add("Execute_StartTime");
                dt_Add.Columns.Add("Execute_EndTime");
                dt_Add.Columns.Add("Execute_Cycle");
                dt_Add.Columns.Add("Execute_DayStartTime");
                dt_Add.Columns.Add("Execute_DayEndTime");
                dt_Add.Columns.Add("Execute_WeekTime");
                dt_Add.Columns.Add("Execute_MonthTime");
                dt_Add.Columns.Add("Enabled");
                dt_Add.Columns.Add("Error_Count");
                dt_Add.Columns.Add("Remind_ErrorCount");
                dt_Add.Columns.Add("Remind_UserName");
                dt_Add.Columns.Add("CreateUser");
                dt_Add.Columns.Add("CreateTime");
                dt_Add.Columns.Add("UpdateUser");
                dt_Add.Columns.Add("UpdateTime");

                DataRow dr = dt_Add.NewRow();

                //循环DataTabel的列
                for (int i = 0; i < dt_Add.Columns.Count-4 ; i++)
                {
                    if (dt_Add.Columns[i].ColumnName == "TASK_ID")
                    {
                        continue;
                    }
                    else
                    {
                        dr[i] = m_request.Tables[0].Rows[0][dt_Add.Columns[i].ColumnName].ToString();   //对DataTabel中的每列设置值
                    }
                }
                dt_Add.Rows.Add(dr);



                if (strTASK_ID == "") //如果为空,说明是复制数据
                {
                    strTASK_ID = Guid.NewGuid().ToString(); //生成GUID

                    dt_Add.Rows[0]["TASK_ID"] = strTASK_ID;
                    dt_Add.Rows[0]["CreateTime"] = DateTime.Now;    //设置创建时间
                    dt_Add.Rows[0]["CreateUser"] = hzyMessage.User_Name;    //设置创建者
                    dt_Add.Rows[0]["UpdateTime"] = DateTime.Now;    //设置更新时间
                    dt_Add.Rows[0]["UpdateUser"] = hzyMessage.User_Name;    //设置更新者
                    dt_Add.Columns.Add("IsDeleted");
                    dt_Add.Rows[0]["IsDeleted"] = false;    //将删除标志设为“False”
                    conn.Insert("WS_Scheduling", dt_Add);   //插入数据
                }
                else
                {
                    //更新
                    dt_Add.Columns.Remove("CreateUser");    //删除CreateUser列,更新不需要
                    dt_Add.Columns.Remove("CreateTime");    //删除CreateTime列,更新不需要
                    dt_Add.Columns.Remove("TASK_ID");
                    dt_Add.Rows[0]["UpdateTime"] = DateTime.Now;    //将更新时间设为当前时间
                    dt_Add.Rows[0]["UpdateUser"] = hzyMessage.User_Name;    //设置更新者

                    strWhere = " TASK_ID = '" + strTASK_ID + "'";   //设置更新条件
                    conn.Update("WS_Scheduling", dt_Add, strWhere); //更新数据
                }

                conn.CommitTransaction();   //提交事务
                return true;
            }
            catch
            {
                conn.RollbackTransaction(); //回滚
                throw;
            }



        }
        /// <summary>
        /// 根据XML内容更新服务器申请单
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds_Return = new DataSet();
                DataSet ds = new DataSet();
                DataSet dsRequest = new DataSet();

                Dbconn conn = new Dbconn("HZY_ExcelAppStore");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                {
                    string strWHERE = " Deleted=0 ";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @" SELECT *
                                FROM    ExcelAppStore WITH ( NOLOCK )
                                WHERE " + strWHERE;
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("ExcelAppStore");
                    conn.BeginTransaction();
                    conn.TableLock(tableList);
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE ExcelAppStore SET Deleted=1 
                               WHERE AppName='" + ds.Tables["LIST"].Rows[i]["AppName"].ToString() + @"'
                                AND Deleted=0 ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM ExcelAppStore WHERE  AppName=@param0
                                AND Deleted=0 ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["AppName"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    //运维操作
                                    if (ds.Tables["LIST"].Rows[i]["AppName"].ToString() != "")
                                    {
                                        conn.Update("ExcelAppStore", dt, "AppName='" + ds.Tables["LIST"].Rows[i]["AppName"].ToString() + @"'");
                                    }

                                }
                                else  //add
                                {

                                    conn.Insert("ExcelAppStore", dt);
                                }

                            }
                        }
                        conn.CommitTransaction();

 
                        ds_Return = Common.Common.GetRequestDataSet(new string[]{"Result"},new string[]{"true"});
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
Пример #22
0
        /// <summary>
        /// 根据XML内容更新付款申请单
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "ISNULL(FNP_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @"SELECT 
                               [FNP_CONO]
                              ,[FNP_DIVI]
                              ,[FNP_PayApplyId]
                              ,[FNP_PayApplyCode]
                              ,[FNP_PR0_ContractId]
                              ,[FNP_SU0_SupplierId]
                              ,[FNP_Type]
                              ,[FNP_BankReceipt]
                              ,[FNP_Status]
                              ,[FNP_RgUser]
                              ,[FNP_RgDt]
                              ,[FNP_LmUser]
                              ,[FNP_LmDt]
                              ,[FNP_UptNo]
                              ,A.PR0_ContractCode
                              ,B.SU0_SupplierCode 
                              ,C.DC0_DICTNAME1 AS  TypeDictName                              
                              ,D.WFT_NODE AS WFT_NODE1
                              ,E.WFT_NODE AS WFT_NODE2
                              ,F.WFT_NODE AS WFT_NODE3
                              ,G.WFT_NODE AS WFT_NODE4

                              ,N.DC0_DICTNAME1 AS DC0_DICTNAME1
                              ,O.DC0_DICTNAME1 AS DC0_DICTNAME2
                              ,P.DC0_DICTNAME1 AS DC0_DICTNAME3
                              ,Q.DC0_DICTNAME1 AS DC0_DICTNAME4

                              ,I.WFP_AuditTime AS WFP_AuditTime1
                              ,J.WFP_AuditTime AS WFP_AuditTime2 
                              ,K.WFP_AuditTime AS WFP_AuditTime3
                              ,L.WFP_AuditTime AS WFP_AuditTime4
                              ,R.[DC0_DictName1] AS StatusDictName
                              FROM  B02_Bill.FNP_PayApply
                              LEFT JOIN  B02_Bill.PR0_Contract A       ON    FNP_PR0_ContractId=A.PR0_ContractId
                              LEFT JOIN  B01_MDM.SU0_Supplier  B       ON    FNP_SU0_SupplierId=B.SU0_SupplierId   
                              LEFT JOIN  M01_CONF.DC0_Dictionary C     ON    FNP_Type=C.DC0_DictId     
                              LEFT JOIN  M02_BPM.WFT_AuditFlowDefine D ON    D.WFT_Type='PayApply' and D.WFT_Step='1'
                              LEFT JOIN  M02_BPM.WFT_AuditFlowDefine E ON    E.WFT_Type='PayApply' and E.WFT_Step='2'
                              LEFT JOIN  M02_BPM.WFT_AuditFlowDefine F ON    F.WFT_Type='PayApply' and F.WFT_Step='3'
                              LEFT JOIN  M02_BPM.WFT_AuditFlowDefine G ON    G.WFT_Type='PayApply' and G.WFT_Step='4'

                              LEFT JOIN  M02_BPM.WFP_AuditFlow I       ON    FNP_PayApplyId=I.WFP_BillId AND I.WFP_WFT_AFDId=D.WFT_AFDId
                              LEFT JOIN  M02_BPM.WFP_AuditFlow J       ON    FNP_PayApplyId=J.WFP_BillId AND J.WFP_WFT_AFDId=E.WFT_AFDId
                              LEFT JOIN  M02_BPM.WFP_AuditFlow K       ON    FNP_PayApplyId=K.WFP_BillId AND K.WFP_WFT_AFDId=F.WFT_AFDId
                              LEFT JOIN  M02_BPM.WFP_AuditFlow L       ON    FNP_PayApplyId=L.WFP_BillId AND L.WFP_WFT_AFDId=G.WFT_AFDId

                              LEFT JOIN  M01_CONF.DC0_Dictionary N     ON    I.WFP_AFResultId=N.DC0_DictId 
                              LEFT JOIN  M01_CONF.DC0_Dictionary O     ON    J.WFP_AFResultId=O.DC0_DictId
                              LEFT JOIN  M01_CONF.DC0_Dictionary P     ON    K.WFP_AFResultId=P.DC0_DictId
                              LEFT JOIN  M01_CONF.DC0_Dictionary Q     ON    L.WFP_AFResultId=Q.DC0_DictId
                              LEFT JOIN  M01_CONF.DC0_Dictionary R     ON    FNP_Status=R.DC0_DictId   
                                WHERE " + strWHERE;
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B02_Bill.FNP_PayApply");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B02_Bill.FNP_PayApply SET FNP_Status='E3CA9B7A-8E17-4E52-B667-39689445D4A1' 
                               WHERE FNP_PayApplyId='" + ds.Tables["LIST"].Rows[i]["FNP_PayApplyId"].ToString() + @"'
                                AND ISNULL(FNP_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B02_Bill.FNP_PayApply WHERE  FNP_PayApplyId=@param0
                                AND ISNULL(FNP_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["FNP_PayApplyId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    //处理结果

                                strSQL = @"SELECT * FROM M02_BPM.WFP_AuditFlow  WHERE  WFP_BillId=@param0
                                         AND  WFP_AFResultId<>'' AND ISNULL(WFP_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                             ";

                                DataTable dt_PA = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["FNP_PayApplyId"].ToString() });
                                //update
                                if (dt_PA.Rows.Count > 0)
                                    {
                                        throw new Exception("付款申请单已审核,不能进行修改!");         
                                    }
                                    else
                                        if (ds.Tables["LIST"].Rows[i]["FNP_LmUser"].ToString() != "")
                                        {
                                            string strCode = dt_SR.Rows[0]["FNP_UptNo"].ToString();
                                            if (strCode == "0")
                                            {
                                                strCode = Convert.ToInt32(strCode) + 1.ToString();
                                            }
                                            else
                                            {
                                                strCode = "0";
                                            }

                                            if (!dt.Columns.Contains("FNP_LmDt"))
                                            {
                                                dt.Columns.Add("FNP_LmDt");
                                            }
                                          //  if (!dt.Columns.Contains("FNP_Status"))
                                          //  {
                                          //      dt.Columns.Add("FNP_Status");
                                          //  }

                                            if (!dt.Columns.Contains("FNP_UptNo"))
                                            {
                                                dt.Columns.Add("FNP_UptNo");
                                            }

                                          //  dt.Rows[0]["FNP_Status"] = '0';
                                            dt.Rows[0]["FNP_LmDt"] = DateTime.Now;
                                            dt.Rows[0]["FNP_UptNo"] = strCode;
                                        }

                                    conn.Update("B02_Bill.FNP_PayApply", dt, "FNP_PayApplyId='" + ds.Tables["LIST"].Rows[i]["FNP_PayApplyId"].ToString() + @"'");

                                }
                                else  //add
                                {


                                    string FNP_PayApplyId = Guid.NewGuid().ToString();


                                    if (!dt.Columns.Contains("FNP_PayApplyId"))
                                    {
                                        dt.Columns.Add("FNP_PayApplyId");
                                    }

                               //    if (!dt.Columns.Contains("FNP_Status"))
                                  //  {
                                  //      dt.Columns.Add("FNP_Status");
                                 //   }

                                    if (!dt.Columns.Contains("FNP_RgDt"))
                                    {
                                        dt.Columns.Add("FNP_RgDt");
                                    }

                                    if (!dt.Columns.Contains("FNP_LmDt"))
                                    {
                                        dt.Columns.Add("FNP_LmDt");
                                    }
                
                                    if (!dt.Columns.Contains("FNP_UptNo"))
                                    {
                                        dt.Columns.Add("FNP_UptNo");
                                    }


                                    dt.Rows[0]["FNP_PayApplyId"] = FNP_PayApplyId;
                                   // dt.Rows[0]["FNP_Status"] = '0';
                                    dt.Rows[0]["FNP_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["FNP_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["FNP_UptNo"] = '0';
                                    conn.Insert("B02_Bill.FNP_PayApply", dt);


                                    GL_ERP_Common.CreateWorkFlow(conn, "PayApply", ds.Tables["LIST"].Rows[i]["FNP_CONO"].ToString(), ds.Tables["LIST"].Rows[i]["FNP_DIVI"].ToString(), FNP_PayApplyId,
                                     "PayApply", "", "", ds.Tables["LIST"].Rows[i]["FNP_Status"].ToString(), ds.Tables["LIST"].Rows[i]["FNP_RgUser"].ToString(),
                                     ds.Tables["LIST"].Rows[i]["FNP_LmUser"].ToString(), "", "FNP_PayApplyId", "B02_Bill.FNP_PayApply");
          
                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
Пример #23
0
        /// <summary>
        /// 对审核步骤进行审核
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                //DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();


                Dbconn conn = new Dbconn("HZY_ITSM");

                string strXML = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();

                DataSet ds = Common.Common.GetDSByExcelXML(strXML);

                string strCheck_ID = "";
                string strCheck_User = "";
                string strCheck_Result = "";
                string strCheck_RemarK = "";
                string strKey_Value = "";
                string strKeyColumn = "";
                string strRequestTableName = "";

                strCheck_ID = ds.Tables["LIST"].Rows[0]["ID"].ToString();
                if (strCheck_ID == "")
                {
                    ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "1:您的请求有误!" });

                    return ds_Return;

                }

                DataTable dt = conn.GetDataTable(@"
                            SELECT  t1.ID ,
                                    t1.Key_ID ,
                                    t1.Seq_Index ,
                                    t1.Seq_Name ,
                                    t1.Check_User ,
                                    t1.Check_Type,
                                    t1.Check_Type_Table_Name,
                                    t1.Check_Type_Key_Column,
                                    t1.Check_Date ,
                                    t1.Check_Result ,
                                    t1.Remark ,
                                    t2.Table_Templete
                            FROM    dbo.Check_List t1
                                    LEFT JOIN dbo.check_Table_Type t2 ON t1.Check_Type = t2.Check_Type
                            WHERE   t1.id = @Param0

                    ", new string[1] { strCheck_ID });

                if (dt.Rows.Count == 0)
                {
                    ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "2:您的请求有误!" });

                    return ds_Return;
                }

                strKey_Value = dt.Rows[0]["Key_ID"].ToString();
                strKeyColumn = dt.Rows[0]["Check_Type_Key_Column"].ToString();
                strRequestTableName = dt.Rows[0]["Check_Type_Table_Name"].ToString();

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                {

                    ITSM_Server_Request_EditByXML itsm_SR = new ITSM_Server_Request_EditByXML();

                    strXML = @"<ROOT><OPTYPE>GET</OPTYPE>
                                        <LIST>
                                        <ROW>    
                                        <condition>" + strKeyColumn + @"='" + strKey_Value + @"'</condition>
                                        </ROW>
                                        </LIST>
                                        </ROOT>";
                    DataSet ds_ITSMSR_Request = Common.Common.GetRequestDataSet(new string[1] { "XML" }, new string[1] { strXML});
                    itsm_SR.Request = ds_ITSMSR_Request;
                    DataSet ds_ITSMSR_Response = itsm_SR.GetData();
                    if (ds_ITSMSR_Response.Tables.Count == 0 || ds_ITSMSR_Response.Tables[0].Rows.Count == 0)
                    {
                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "3:获取原始单据有误!" });
                        return ds_Return;
                    }

                    string strTableTemplete = dt.Rows[0]["Table_Templete"].ToString();
                    for (int i = 0; i < ds_ITSMSR_Response.Tables[0].Columns.Count; i++)
                    {
                        string strTemp = ds_ITSMSR_Response.Tables[0].Rows[0][i].ToString().Replace("\n", "<p>");
                        if(strTemp == "")
                        {
                            strTemp = "&nbsp;";
                        }
                        strTableTemplete = strTableTemplete.Replace("[@@" + ds_ITSMSR_Response.Tables[0].Columns[i].ColumnName + "]", strTemp);
                    }
                    dt.Rows[0]["Table_Templete"] = Microsoft.JScript.GlobalObject.escape(strTableTemplete);

                    dt.Columns.Add("timestamps");
                    dt.Rows[0]["timestamps"] = ds_ITSMSR_Response.Tables[0].Rows[0]["timestamps"];

                    ds_Return.Tables.Add(dt.Copy());
                   

                }
                else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                {

                    strCheck_ID = ds.Tables["LIST"].Rows[0]["ID"].ToString();
                    strCheck_User = ds.Tables["LIST"].Rows[0]["Check_User"].ToString();
                    strCheck_Result = ds.Tables["LIST"].Rows[0]["Check_Result"].ToString();
                    strCheck_RemarK = ds.Tables["LIST"].Rows[0]["Check_Remark"].ToString();

                    DataTable dtCheckList = conn.GetDataTable("SELECT * FROM Check_List WHERE ID='" + strCheck_ID + "'");

                    if (dt.Rows.Count == 0)
                    {
                        throw new Exception("该审核单已不存在,请联系管理员");
                    }

                    int nSeq_ID = Convert.ToInt32(dt.Rows[0]["Seq_Index"]);

                    //判断是否已经进行后续的审批
                    string strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
                                AND Key_ID='" + dt.Rows[0]["Key_ID"].ToString() + @"'
                                AND Check_Result is not null
                                AND Seq_Index>" + nSeq_ID.ToString() + "";

                    if (conn.GetDataTableRowCount(strSql) > 0)
                    {
                        throw new Exception("下一道的流程已经审批,本次审批不能再做修改!");
                    }


                    dtCheckList.Rows[0]["Check_User"] = strCheck_User;
                    dtCheckList.Rows[0]["Check_Date"] = DateTime.Now;
                    dtCheckList.Rows[0]["Check_Result"] = strCheck_Result;
                    dtCheckList.Rows[0]["Remark"] = strCheck_RemarK;
                    dtCheckList.Rows[0]["updateTime"] = DateTime.Now;

                    ArrayList listTable = new ArrayList();
                    listTable.Add("Check_List");

                    try
                    {
                        conn.BeginTransaction();
                        conn.TableLock(listTable);

                        //判断数据是否为最新数据
                        strSql = "SELECT timestamps+0 as timestamps from " + strRequestTableName
                            + " WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";

                        string strTimestamps = conn.GetDataTableFirstValue(strSql).ToString();
                        if (strTimestamps != ds.Tables["LIST"].Rows[0]["timestamps"].ToString())
                        {
                            throw new Exception("原申请单数据已被修改,请刷新后重试!");
                        }
                        //dt.Columns.Remove("timestamps");
                        conn.Update("Check_List", dtCheckList, "ID='" + strCheck_ID + "'");


                        string[] strColumn = new string[3];
                        string[] strValue = new string[3];
                        strColumn[0] = "Check_Type";
                        strColumn[1] = "Seq_Name";
                        strColumn[2] = "Key_ID";

                        strValue[0] = dt.Rows[0]["Check_Type"].ToString();
                        strValue[1] = dt.Rows[0]["Seq_Name"].ToString();
                        strValue[2] = dt.Rows[0]["Key_ID"].ToString();

                        DataSet requestDs = Common.Common.GetRequestDataSet(strColumn, strValue);

                        ITSM_Check_List_Edit checkListEdit = new ITSM_Check_List_Edit();
                        checkListEdit.Conn = conn;
                        checkListEdit.ListAMSendList = listAMSendList;
                        checkListEdit.Request = requestDs;
                        checkListEdit.Execute();

                        if (strCheck_Result != "同意")
                        {
                            //更新原表的状态为已驳回
                            strSql = "UPDATE " + strRequestTableName + " SET State='已驳回' WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
                            conn.ExcuteQuerryByTran(strSql);
                        }
                        else
                        {
                            //判断是否有已驳回的状态
                            strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
                                AND Key_ID='" + strKey_Value + @"'
                                AND (Seq_index = " + nSeq_ID.ToString() + @" 
                                AND Check_Result='已驳回')";

                            //没有已驳回的记录
                            if (conn.GetDataTableRowCount(strSql) == 0)
                            {
                                //判断是否还有后续的流程
                                strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
                                AND Key_ID='" + strKey_Value + @"'
                                AND (Seq_Index>" + nSeq_ID.ToString() + @"
                                OR (Seq_Index=" + nSeq_ID.ToString() + @"
                                AND Must_Check=1
                                AND Check_Date IS NULL
                                ))";

                                if (conn.GetDataTableRowCount(strSql) == 0)
                                {
                                    //更新原表的状态为已审核
                                    strSql = "UPDATE " + strRequestTableName + " SET State='已审核' WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
                                    conn.ExcuteQuerryByTran(strSql);

                                    ITSM_Common.SendAMMessage("", "马卫清", "有服务器申请表需要操作", "您有有服务器申请表需要操作,请进入EXCEL操作");
                                }
                                else
                                {
                                    //更新原表的状态为审核中
                                    strSql = "UPDATE " + strRequestTableName + " SET State='审核中' WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
                                    conn.ExcuteQuerryByTran(strSql);
                                }
                            }
                        }

                        conn.CommitTransaction();

                        for (int i = 0; i < listAMSendList.Count; i++)
                        {
                            string[] strList = (string[])(listAMSendList[i]);
                            ITSM_Common.SendAMMessage(strList[0], strList[1], strList[2]);
                        }

                    }
                    catch (Exception)
                    {
                        conn.RollbackTransaction();
                        throw;
                    }

                    ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
        public bool Execute()
        {
            string strSystem_Fid = "144";
            string strSystem_id = "ST0301A";
            string strSystem_Name = "F22分销系统 CS总部版";
            string strCompany_id = "235";
            Dbconn conn = new Dbconn("F22");
            Dbconn conn_MDM = new Dbconn("MDM");

            //取到总部的数据
            DataSet ds = conn.GetDataSet(
                @"  SELECT  userid ,
                            username
                    FROM    j_user t1 WITH ( NOLOCK )
                    WHERE   1 = 1
                            AND dptype = 0
                            AND notuse = 0
 	                    ");


            DataTable dt_Add = new DataTable();
            dt_Add.Columns.Add("System_FID");
            dt_Add.Columns.Add("System_ID");
            dt_Add.Columns.Add("System_Name");
            dt_Add.Columns.Add("AM_User_ID");
            dt_Add.Columns.Add("AM_Login");
            dt_Add.Columns.Add("Company_ID");
            dt_Add.Columns.Add("System_User_ID");
            dt_Add.Columns.Add("System_User_Name");
            dt_Add.Columns.Add("Create_AM_User_ID");
            dt_Add.Columns.Add("CreateTime");
            dt_Add.Columns.Add("UpdateTime");

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string strName = ds.Tables[0].Rows[i]["username"].ToString();
                string strUserID = ds.Tables[0].Rows[i]["userid"].ToString();

                DataTable dt_AM = conn_MDM.GetDataTable(@"SELECT AM_User_ID,AM_login FROM dbo.AM_User
                                                WHERE AM_LOGIN=@param0", new string[1] { strName });
                if (dt_AM.Rows.Count > 0)
                {
                    DataRow dr_add = dt_Add.NewRow();
                    dr_add["System_FID"] = strSystem_Fid;
                    dr_add["System_ID"] = strSystem_id;
                    dr_add["System_Name"] = strSystem_Name;
                    dr_add["AM_User_ID"] = dt_AM.Rows[0]["AM_User_ID"].ToString();
                    dr_add["AM_Login"] = dt_AM.Rows[0]["AM_Login"].ToString();

                    dr_add["Company_ID"] = strCompany_id;

                    dr_add["System_User_ID"] = strUserID;
                    dr_add["System_User_Name"] = strName;
                    dr_add["Create_AM_User_ID"] = "0"; //默认为系统自动建立
                    dr_add["CreateTime"] = DateTime.Now;
                    dr_add["UpdateTime"] = DateTime.Now;
                    dt_Add.Rows.Add(dr_add);
                }
            }

            if (dt_Add.Rows.Count > 0)
            {
                ArrayList listLockTable = new ArrayList();
                listLockTable.Add("SSO_System_Relation");

                conn_MDM.BeginTransaction();
                try
                {
                    conn_MDM.TableLock(listLockTable);
                    conn_MDM.Excute("DELETE FROM SSO_System_Relation WHERE System_FID='" + strSystem_Fid + "'");
                    conn_MDM.InsertBYSQLBC("SSO_System_Relation", dt_Add);
                    conn_MDM.CommitTransaction();
                }
                catch (Exception)
                {
                    conn_MDM.RollbackTransaction();
                    throw;
                }

            }

            return true;

        }
Пример #25
0
        /// <summary>
        /// 部署WS
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            Dbconn conn = new Dbconn("WSRR");
            Dbconn connDeploy = new Dbconn("WSRR_Deploy");

            try
            {
                if(m_request == null
                    || m_request.Tables.Count==0
                    || m_request.Tables[0].Rows.Count == 0)
                {
                    return true;
                }
                string strWS_ID = m_request.Tables[0].Rows[0]["WS_ID"].ToString();

                string strSQL = "";

                DataSet ds = conn.GetDataSet(@"
                            SELECT * FROM dbo.WS
                            WHERE WS_ID=@param0;

                            SELECT * FROM dbo.WS_Param
                            WHERE WS_ID=@param0",new string[]{strWS_ID});

                if (ds.Tables.Count !=2 || ds.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("WS_ID的信息不正确!");
                }
                string strENV =  ConfigurationManager.AppSettings["WSRR_ENV"];

                if (strENV.ToLower() == "prod")
                {
                    ds.Tables[0].Rows[0]["WS_Host"] = ds.Tables[0].Rows[0]["WS_Host_Test"].ToString();
                }
                else
                {
                    ds.Tables[0].Rows[0]["WS_Host"] = ds.Tables[0].Rows[0]["WS_Host_Prod"].ToString();
                }

                ArrayList tableList = new ArrayList();
                tableList.Add("WS");
                tableList.Add("WS_Param");
                connDeploy.BeginTransaction();
                connDeploy.TableLock(tableList);

                connDeploy.Delete("WS", "WS_ID='" + strWS_ID + "'");
                connDeploy.Delete("WS_Param", "WS_ID='" + strWS_ID + "'");

                connDeploy.Insert("WS", ds.Tables[0]);
                connDeploy.Insert("WS_Param", ds.Tables[1]);
                connDeploy.CommitTransaction();

                return true;
            }
            catch
            {
                conn.RollbackTransaction();
                throw;
            }



        }
        /// <summary>
        /// 根据XML内容更新到货计划字表
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

          
              if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "isnull(PRAD_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";
                    string strWHERE1 = "isnull(PRAD_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'"; 
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                         if (ds.Tables["LIST"].Rows[0]["Condition1"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE1 += " AND (" + ds.Tables["LIST"].Rows[0]["Condition1"].ToString().Trim() + ")";
                        }

                    }
                     
                    strSQL = @"SELECT * FROM B02_Bill.PRAD_ArrivalPlanDetail WHERE " + strWHERE;
                                
                       DataTable dt_SR = conn.GetDataTable(strSQL);

                        if (dt_SR.Rows.Count > 0)
                        {
                            strSQL = @"SELECT
                                       [PRAD_CONO]
                                      ,[PRAD_DIVI]
                                      ,[PRAD_ArrivalPlanDetailId]
                                      ,[PRAD_PRA_ArrivalPlanId]
                                      ,[PRAD_PD0_ProductId]
                                      ,[PRAD_UnitID]
                                      ,[PRAD_PR1D_OrderDetailId]
                                      ,[PRAD_ArrivalDate]
                                      ,[PRAD_PerchaseTotal]
                                      ,[PRAD_ArrivalTotal]
                                      ,[PRAD_PlanTotal]
                                      ,[PRAD_PlanArrival]
                                      ,[PRAD_PlanArrivalAmount]
                                      ,[PRAD_TotalDiff]
                                      ,[PRAD_Status]
                                      ,[PRAD_RgUser]
                                      ,[PRAD_RgDt]
                                      ,[PRAD_LmUser]
                                      ,[PRAD_LmDt]
                                      ,[PRAD_UptNo]
                             FROM  B02_Bill.PRAD_ArrivalPlanDetail 
                             WHERE " + strWHERE;
                        }
                         
                      else
                       {
                           strSQL = @"SELECT  
                                 [PRAD_CONO]
                                ,[PRAD_DIVI]      
                                ,'' AS [PRAD_ArrivalPlanDetailId]                                   
                                ,[PRA_ArrivalPlanId]
                                ,[PR1D_OrderDetailId] 
                                ,[PR1D_PD0_ProductId]                                                     
                                ,[PR1D_UnitID]
                                ,'' AS [PRAD_ArrivalDate]
                                ,ISNULL([PR1D_Total],'0') AS [PR1D_Total]
                                ,SUM(ISNULL(PRAD_PlanArrival,'0')) AS PRAD_PlanTotal
                                ,SUM(ISNULL([PRAD_ArrivalTotal],'0')) as PRAD_ArrivalTotal
                                ,'0' AS  [PRAD_PlanArrival] 
                                ,'0' AS  [PRAD_PlanArrivalAmount]
                                ,'0' as [PRAD_TotalDiff]
                                ,'' as [PRAD_Status]   
                                ,'' as [PRAD_RgUser]
                                ,'' as [PRAD_RgDt]
                                ,'' as [PRAD_LmUser]
                                ,'' as [PRAD_LmDt]
                                ,'0' as [PRAD_UptNo]
                            FROM  B02_Bill.PRA_ArrivalPlan 
                            LEFT JOIN B02_Bill.PR1D_OrderDetail  ON PRA_PR1_OrderId=PR1D_PR1_OrderId
                            LEFT JOIN B02_Bill.PRAD_ArrivalPlanDetail ON PR1D_OrderDetailId=PRAD_PR1D_OrderDetailId  
                            WHERE " + strWHERE1
                             + @"GROUP BY  [PRAD_CONO],[PRAD_DIVI] ,[PRA_ArrivalPlanId],[PR1D_PD0_ProductId]
                                ,[PR1D_OrderDetailId],[PR1D_UnitID]    
                                ,[PR1D_Total]";                            
                            
                         }
                        ds_Return = conn.GetDataSet(strSQL); 

                   // }
                 }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B02_Bill.PRAD_ArrivalPlanDetail");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B02_Bill.PRAD_ArrivalPlanDetail SET PRAD_Status='E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                               WHERE PRAD_PRA_ArrivalPlanId='" + ds.Tables["LIST"].Rows[i]["PRAD_PRA_ArrivalPlanId"].ToString() + @"'
                               AND iusnull(PRA_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B02_Bill.PRAD_ArrivalPlanDetail WHERE  PRAD_ArrivalPlanDetailId=@param0
                                AND PRAD_Status<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                 ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PRAD_ArrivalPlanDetailId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                { 
                                    //处理结果
                                    if (ds.Tables["LIST"].Rows[i]["PRAD_LmUser"].ToString() != "")
                                    {
                                        string strCode = dt_SR.Rows[0]["PRAD_UptNo"].ToString();
                                        if (strCode == "0")
                                        {
                                            strCode = Convert.ToInt32(strCode) + 1.ToString();
                                        }
                                        else
                                        {
                                            strCode = "0";
                                        }

                                        if (!dt.Columns.Contains("PRAD_LmDt"))
                                        {
                                            dt.Columns.Add("PRAD_LmDt");
                                        }


                                        if (!dt.Columns.Contains("PRAD_UptNo"))
                                        {
                                            dt.Columns.Add("PRAD_UptNo");
                                        }

                                        //if (!dt.Columns.Contains("PRA_Status"))
                                        //{
                                        //    dt.Columns.Add("PRA_Status");
                                        //}

                                        //dt.Rows[0]["PRA_Status"] = '0';
                                        dt.Rows[0]["PRA_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["PRA_UptNo"] = strCode;
                                    }

                                    conn.Update("B02_Bill.PRAD_ArrivalPlanDetail", dt, "PRAD_ArrivalPlanDetailId='" + ds.Tables["LIST"].Rows[i]["PRAD_ArrivalPlanDetailId"].ToString() + @"'");
                                  
                                    strSQL = @"UPDATE AA SET AA.PR1_PurchaseTotal=BB.PR1_PurchaseTotal,
                                               AA.PR1_PurchaseAmount=BB.PR1_PurchaseAmount,AA.PR1_POriginalAmount=BB.PR1_POriginalAmount,
                                               AA.PR1_LmUser='******',
                                               AA.PR1_LmDt='" + ds.Tables["LIST"].Rows[i]["PR1D_LmDt"].ToString() + @"',
                                               AA.PR1_UptNo=AA.PR1D_UptNo+1
                                               FROM 
                                               B02_Bill.PR1_Order AA,
                                               (SELECT SUM(PR1D_Total) AS PR1_PurchaseTotal,SUM(PR1D_OriginalAmount) AS PR1_PurchaseAmount,
                                                SUM(PR1D_EstimateCost) AS PR1D_EstimateCost,SUM(PR1D_CurrencyAmount) AS PR1_POriginalAmount,PR1D_PR1_OrderId
                                                FROM B02_Bill.PR1D_OrderDetail WHERE PR1D_PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
                                                GROUP BY PR1D_PR1_OrderId)BB
                                                WHERE AA.PR1_OrderId=BB.PR1D_PR1_OrderId";
                                    conn.ExcuteQuerryByTran(strSQL);

                                }

                                else  //add
                                {

                                    DataTable dtTemp = conn.GetDataTableInTrans(
                                      @" SELECT   " + ds.Tables["LIST"].Rows[i]["PRAD_PerchaseTotal"].ToString() + @"  -
                                         " + ds.Tables["LIST"].Rows[i]["PRAD_ArrivalTotal"].ToString() + @" -
                                         " + ds.Tables["LIST"].Rows[i]["PRAD_PlanArrival"].ToString() + @"  as PRAD_TotalDiff
                                      ");

                                    string PRAD_TotalDiff = dtTemp.Rows[0]["PRAD_TotalDiff"].ToString();


                                    DataTable dtAmot = conn.GetDataTableInTrans(
                                     @" SELECT  ISNULL(PR1D_POriginalPrice * " + ds.Tables["LIST"].Rows[i]["PRAD_PlanArrival"].ToString() + @",'0')
                                        as PRAD_PlanArrivalAmount 
                                        FROM  B02_Bill.PR1D_OrderDetail   WHERE PR1D_OrderDetailId='" + ds.Tables["LIST"].Rows[i]["PRAD_PR1D_OrderDetailId"].ToString() + @"'
                                        AND  PR1D_PD0_ProductId='" + ds.Tables["LIST"].Rows[i]["PRAD_PD0_ProductId"].ToString() + @"'
                                      ");

                                    string PRAD_PlanArrivalAmount = dtAmot.Rows[0]["PRAD_PlanArrivalAmount"].ToString();
 
                                    string PRAD_ArrivalPlanDetailId = Guid.NewGuid().ToString();


                                    if (!dt.Columns.Contains("PRAD_ArrivalPlanDetailId"))
                                    {
                                        dt.Columns.Add("PRAD_ArrivalPlanDetailId");
                                    }


                                    if (!dt.Columns.Contains("PRAD_RgDt"))
                                    {
                                        dt.Columns.Add("PRAD_RgDt");
                                    }

                                    if (!dt.Columns.Contains("PRAD_LmDt"))
                                    {
                                        dt.Columns.Add("PRAD_LmDt");
                                    }

                                    if (!dt.Columns.Contains("PRAD_UptNo"))
                                    {
                                        dt.Columns.Add("PRAD_UptNo");
                                    }

                                    if (!dt.Columns.Contains("PRAD_TotalDiff"))
                                    {
                                        dt.Columns.Add("PRAD_TotalDiff");
                                    }

                                    if (!dt.Columns.Contains("PRAD_PlanArrivalAmount"))
                                    {
                                        dt.Columns.Add("PRAD_PlanArrivalAmount");
                                    }


                                    dt.Rows[0]["PRAD_ArrivalPlanDetailId"] = PRAD_ArrivalPlanDetailId;

                                    dt.Rows[0]["PRAD_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["PRAD_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["PRAD_TotalDiff"] = PRAD_TotalDiff;
                                    dt.Rows[0]["PRAD_PlanArrivalAmount"] = PRAD_PlanArrivalAmount;

                                    conn.Insert("B02_Bill.PRAD_ArrivalPlanDetail", dt);

 

                                    strSQL = @"UPDATE AA SET AA.PRA_PlanTotal=BB.PRAD_PlanTotal,
                                                AA.PRA_PlanAmount=BB.PRAD_PlanArrivalAmount,
                                                AA.PRA_LmUser='******',
                                                AA.PRA_LmDt=CONVERT(VARCHAR(100),GETDATE(),121),
                                                AA.PRA_TotalDiff=AA.PRA_PerchaseTotal-AA.PRA_ArrivalTotal-BB.PRA_PlanTotal,
                                                AA.PRA_AmountDiff=AA.PRA_PerchaseAmount-AA.PRA_ArrivalAmount-BB.PRA_PlanAmount, 
                                                AA.PRA_UptNo=AA.PRA_UptNo+1
                                                FROM 
                                                PRA_ArrivalPlan AA,
                                               (SELECT PRAD_PRA_ArrivalPlanId,SUM(ISNULL(PRAD_PlanArrival,'0')) AS PRAD_PlanTotal,              
                                                SUM(ISNULL(PRAD_PlanArrivalAmount,'0')) AS PRAD_PlanArrivalAmount                                       
                                                FROM   B02_Bill.PRAD_ArrivalPlanDetail 
                                                WHERE  PRAD_PRA_ArrivalPlanId=' " + ds.Tables["LIST"].Rows[i]["PRAD_PRA_ArrivalPlanId"].ToString() + @" '
                                                GROUP BY PRAD_PRA_ArrivalPlanId)BB
                                                WHERE AA.PRA_ArrivalPlanId=BB.PRAD_PRA_ArrivalPlanId";
                                        
                                    conn.ExcuteQuerryByTran(strSQL);




//                                    strSQL = @"UPDATE AA SET AA.PR1_PurchaseTotal=BB.PR1_PurchaseTotal,
//                                               AA.PR1_PurchaseAmount=BB.PR1_PurchaseAmount,AA.PR1_POriginalAmount=BB.PR1_POriginalAmount,
//                                               AA.PR1_LmUser='******',
//                                               AA.PR1_LmDt='" + ds.Tables["LIST"].Rows[i]["PR1D_LmDt"].ToString() + @"',
//                                               AA.PR1_UptNo=AA.PR1D_UptNo+1
//                                               FROM 
//                                               B02_Bill.PR1_Order AA,
//                                               (SELECT SUM(PR1D_Total) AS PR1_PurchaseTotal,SUM(PR1D_OriginalAmount) AS PR1_PurchaseAmount,
//                                                SUM(PR1D_EstimateCost) AS PR1D_EstimateCost,SUM(PR1D_CurrencyAmount) AS PR1_POriginalAmount,PR1D_PR1_OrderId
//                                                FROM B02_Bill.PR1D_OrderDetail WHERE PR1D_PR1_OrderId='" + ds.Tables["LIST"].Rows[i]["PR1D_PR1_OrderId"].ToString() + @"'
//                                                GROUP BY PR1D_PR1_OrderId)BB
//                                                WHERE AA.PR1_OrderId=BB.PR1D_PR1_OrderId";
                                 //   conn.ExcuteQuerryByTran(strSQL);
                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
        /// <summary>
        /// 根据XML内容更新到货计划
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet ds_Return = new DataSet();
                DataSet dsRequest = new DataSet();

                ArrayList listAMSendList = new ArrayList();

                Dbconn conn = new Dbconn("GL_ERP");

                string strXML = "";
                string strSQL = "";
                strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
                //XML是前台传入
                ds = Common.Common.GetDSByExcelXML(strXML);

                if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "GET")
                //读取ROWS到/ROWS 中的参数
                {
                    string strWHERE = "isnull(PRA_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'";
                    if (ds.Tables["LIST"].Columns.Contains("Condition"))
                    {
                        if (ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() != "")
                        //读取LIST之间参数
                        {
                            strWHERE += " AND (" + ds.Tables["LIST"].Rows[0]["Condition"].ToString().Trim() + ")";
                        }
                    }

                    strSQL = @" SELECT 
                                [PRA_CONO]
                               ,[PRA_DIVI]
                               ,[PRA_ArrivalPlanId]
                               ,[PRA_ArrivalPlanCode]
                               ,[PRA_PR1_OrderId]
                               ,[PRA_PerchaseTotal]
                               ,[PRA_ArrivalTotal]
                               ,[PRA_PlanTotal]
                               ,[PRA_PerchaseAmount]
                               ,[PRA_ArrivalAmount]
                               ,[PRA_PlanAmount]
                               ,[PRA_TotalDiff]
                               ,[PRA_AmountDiff]
                               ,[PRA_Status]
                               ,[PRA_RgUser]
                               ,[PRA_RgDt]
                               ,[PRA_LmUser]
                               ,[PRA_LmDt]
                               ,[PRA_UptNo]
                               ,A.PR1_OrderCode
                               FROM B02_Bill.PRA_ArrivalPlan
                               LEFT JOIN B02_Bill.PR1_Order A ON PRA_PR1_OrderId=PR1_OrderId                           
                               WHERE " + strWHERE;
                    ds_Return = conn.GetDataSet(strSQL);
                }
                else
                {

                    ArrayList tableList = new ArrayList();
                    tableList.Add("B02_Bill.PRA_ArrivalPlan");
                    conn.BeginTransaction();
                    //开启事物
                    conn.TableLock(tableList);
                    //锁表
                    try
                    {
                        if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "DELETE")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                strSQL = @"UPDATE B02_Bill.PRA_ArrivalPlan SET PRA_Status='E3CA9B7A-8E17-4E52-B667-39689445D4A1' 
                               WHERE PRA_ArrivalPlanId='" + ds.Tables["LIST"].Rows[i]["PRA_ArrivalPlanId"].ToString() + @"'
                                AND isnull(PRA_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1' 
                                ";
                                conn.ExcuteQuerryByTran(strSQL);
                            }

                        }
                        else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
                        {
                            for (int i = 0; i < ds.Tables["LIST"].Rows.Count; i++)
                            {
                                DataTable dt = ds.Tables["LIST"].Clone();
                                dt.ImportRow(ds.Tables["LIST"].Rows[i]);

                                strSQL = @"SELECT * FROM B02_Bill.PRA_ArrivalPlan WHERE  PRA_ArrivalPlanId=@param0
                                AND isnull(PRA_Status,'')<>'E3CA9B7A-8E17-4E52-B667-39689445D4A1'
                                 ";

                                DataTable dt_SR = conn.GetDataTable(strSQL, new string[1] { ds.Tables["LIST"].Rows[i]["PRA_ArrivalPlanId"].ToString() });
                                //update
                                if (dt_SR.Rows.Count > 0)
                                {
                                    //处理结果
                                    if (ds.Tables["LIST"].Rows[i]["PRA_LmUser"].ToString() != "")
                                    {
                                        string strCode = dt_SR.Rows[0]["PRA_UptNo"].ToString();
                                        if (strCode == "0")
                                        {
                                            strCode = Convert.ToInt32(strCode) + 1.ToString();
                                        }
                                        else
                                        {
                                            strCode = "0";
                                        }

                                        if (!dt.Columns.Contains("PRA_LmDt"))
                                        {
                                            dt.Columns.Add("PRA_LmDt");
                                        }


                                        if (!dt.Columns.Contains("PRA_UptNo"))
                                        {
                                            dt.Columns.Add("PRA_UptNo");
                                        }

                                       // if (!dt.Columns.Contains("PRA_Status"))
                                       // {
                                       //     dt.Columns.Add("PRA_Status");
                                       // }

                                       // dt.Rows[0]["PRA_Status"] = '0';
                                        dt.Rows[0]["PRA_LmDt"] = DateTime.Now;
                                        dt.Rows[0]["PRA_UptNo"] = strCode;
                                    }

                                    conn.Update("B02_Bill.PRA_ArrivalPlan", dt, "PRA_ArrivalPlanId='" + ds.Tables["LIST"].Rows[i]["PRA_ArrivalPlanId"].ToString() + @"'");

                  
                                    }            

                                else  //add
                                {

                                    string PRA_ArrivalPlanId = Guid.NewGuid().ToString();


                                    if (!dt.Columns.Contains("PRA_ArrivalPlanId"))
                                    {
                                        dt.Columns.Add("PRA_ArrivalPlanId");
                                    }

                                  //  if (!dt.Columns.Contains("PRA_Status"))
                                  //  {
                                  //      dt.Columns.Add("PRA_Status");
                                  //  }


                                    if (!dt.Columns.Contains("PRA_RgDt"))
                                    {
                                        dt.Columns.Add("PRA_RgDt");
                                    }

                                    if (!dt.Columns.Contains("PRA_LmDt"))
                                    {
                                        dt.Columns.Add("PRA_LmDt");
                                    }

                                    if (!dt.Columns.Contains("PRA_UptNo"))
                                    {
                                        dt.Columns.Add("PRA_UptNo");
                                    }


                                    dt.Rows[0]["PRA_ArrivalPlanId"] = PRA_ArrivalPlanId;

                                    dt.Rows[0]["PRA_RgDt"] = DateTime.Now;
                                    dt.Rows[0]["PRA_LmDt"] = DateTime.Now;
                                    dt.Rows[0]["PRA_UptNo"] = '0';
                                  //  dt.Rows[0]["PRA_Status"] = '0';

                                    conn.Insert("B02_Bill.PRA_ArrivalPlan", dt);


                                }

                            }
                        }
                        conn.CommitTransaction();



                        ds_Return = Common.Common.GetRequestDataSet(new string[] { "Result" }, new string[] { "true" });
                    }
                    catch
                    {
                        conn.RollbackTransaction();
                        //事物结束
                        throw;
                    }
                }
                return ds_Return;
            }
            catch
            {
                throw;
            }

        }
Пример #28
0
        public bool Execute()
        {

            Dbconn conn = new Dbconn("DBDict");

            //取到所有的数据库服务器
            DataTable dt_DBServer = conn.GetDataTable("SELECT * FROM DBServer ", new string[0]);

            //清空数据
            conn.ExcuteQuerryByTran(@"
                    TRUNCATE TABLE DBDict.dbo.TableDict
                    TRUNCATE TABLE DBDict.dbo.TableSize
                    TRUNCATE TABLE DBDict.dbo.DBInfo
                    TRUNCATE TABLE DBDict.dbo.TableIndex
                    TRUNCATE TABLE DBDict.dbo.DBOtherInfo
                    TRUNCATE TABLE DBDict.dbo.LinkServers
                ");


            if (dt_DBServer.Rows.Count > 0)
            {

                for (int i = 0; i < dt_DBServer.Rows.Count; i++)
                {
                    string strConnString = "DataBase=master;Password="******"sql密码"].ToString() + ";User ID=" + dt_DBServer.Rows[i]["sql用户名"].ToString() + ";Data Source=" + dt_DBServer.Rows[i]["ip"].ToString() + ";";

                    string strSQL = "SELECT Name FROM Master..SysDatabases ORDER BY Name";


                    Dbconn conn_AllDB = new Dbconn(strConnString, true);

                    //所有的数据库名
                    DataTable dt_AllDB = conn_AllDB.GetDataTable(strSQL, new string[0]);

                    for (int k = 0; k < dt_AllDB.Rows.Count; k++)
                    {

                        if (dt_AllDB.Rows[k][0].ToString() == "tempdb")
                        {
                            continue;
                        }

                        strConnString = "DataBase=" + dt_AllDB.Rows[k][0].ToString() + ";Password="******"sql密码"].ToString() + ";User ID=" + dt_DBServer.Rows[i]["sql用户名"].ToString() + ";Data Source=" + dt_DBServer.Rows[i]["ip"].ToString() + ";";

                        Dbconn conn_DB = new Dbconn(strConnString, true);


                        string str_获取数据库中所有表的字段属性 = @"
SELECT  @@SERVERNAME 服务器,db_name() 数据库名,d.name AS 表名, 
      CASE WHEN a.colorder = 1 THEN isnull(f.value, '') ELSE '' END AS 表说明, 
      a.colorder AS 字段序号, a.name AS 字段名, CASE WHEN COLUMNPROPERTY(a.id, 
      a.name, 'IsIdentity') = 1 THEN '√' ELSE '' END AS 标识, 
      CASE WHEN EXISTS
          (SELECT 1
         FROM dbo.sysindexes si INNER JOIN
               dbo.sysindexkeys sik ON si.id = sik.id AND si.indid = sik.indid INNER JOIN
               dbo.syscolumns sc ON sc.id = sik.id AND sc.colid = sik.colid INNER JOIN
               dbo.sysobjects so ON so.name = si.name AND so.xtype = 'PK'
         WHERE sc.id = a.id AND sc.colid = a.colid) THEN '√' ELSE '' END AS 主键, 
      b.name AS 类型, a.length AS 长度, COLUMNPROPERTY(a.id, a.name, 'PRECISION') 
      AS 精度, ISNULL(COLUMNPROPERTY(a.id, a.name, 'Scale'), 0) AS 小数位数, 
      CASE WHEN a.isnullable = 1 THEN '√' ELSE '' END AS 允许空, ISNULL(e.text, '') 
      AS 默认值, ISNULL(g.[value], '') AS 字段说明, d.crdate AS 创建时间, 
      CASE WHEN a.colorder = 1 THEN d.refdate ELSE NULL END AS 更改时间,
      GETDATE() 采集时间
FROM dbo.syscolumns a with(nolock)  LEFT OUTER JOIN
      dbo.systypes b with(nolock)  ON a.xtype = b.xusertype INNER JOIN
      dbo.sysobjects d with(nolock)  ON a.id = d.id AND d.xtype = 'U' AND 
      d.status >= 0 LEFT OUTER JOIN
      dbo.syscomments e with(nolock)  ON a.cdefault = e.id LEFT OUTER JOIN
      sys.extended_properties g with(nolock)  ON a.id = g.major_id AND a.colid = g.minor_id AND 
      g.name = 'MS_Description' LEFT OUTER JOIN
      sys.extended_properties f with(nolock)  ON d.id = f.major_id AND f.minor_id = 0 AND 
      f.name = 'MS_Description'
ORDER BY d.name, 字段序号	
        ";


                        string str_显示当前数据库中用户表的记录数量及大小 = @"
SELECT @@servername 服务器,db_name() 数据库,OBJECT_NAME(id) AS 表名,
       rowcnt AS 记录数量,
       8 * reserved / 1024 AS '大小(MB)',
       GETDATE() 采集时间
FROM   sysindexes a with(nolock) 
       LEFT JOIN sys.objects b with(nolock) 
            ON  a.name = b.name
WHERE  indid < 2
       AND OBJECTPROPERTY(id, 'isusertable ') = 1
ORDER BY
       rowcnt DESC
";


                        string str_查询所有表的索引 = @"
SELECT @@SERVERNAME AS 服务器,DB_NAME() AS 数据库, 
      c.name AS 表名, 
      a.name AS 索引名称, d.name AS 列名, 
      b.keyno AS 索引顺序, CASE indexkey_property(c.id, b.indid, b.keyno, 'isdescending') 
      WHEN 1 THEN '降序' WHEN 0 THEN '升序' END AS 排序, CASE WHEN p.id IS NULL 
      THEN '' ELSE '√' END AS 主键, CASE INDEXPROPERTY(c.id, a.name, 'IsClustered') 
      WHEN 1 THEN '√' WHEN 0 THEN '' END AS 聚集, CASE INDEXPROPERTY(c.id, 
      a.name, 'IsUnique') WHEN 1 THEN '√' WHEN 0 THEN '' END AS 唯一, 
      CASE WHEN e.id IS NULL THEN '' ELSE '√' END AS 唯一约束, 
      a.OrigFillFactor AS 填充因子, c.crdate AS 创建时间, c.refdate AS 更改时间,
      GETDATE() AS 采集时间
FROM dbo.sysindexes a with(nolock)  INNER JOIN
      dbo.sysindexkeys b with(nolock) ON a.id = b.id AND a.indid = b.indid INNER JOIN
      dbo.syscolumns d with(nolock) ON b.id = d.id AND b.colid = d.colid INNER JOIN
      dbo.sysobjects c with(nolock) ON a.id = c.id AND c.xtype = 'U' LEFT OUTER JOIN
      dbo.sysobjects e with(nolock) ON e.name = a.name AND e.xtype = 'UQ' LEFT OUTER JOIN
      dbo.sysobjects p with(nolock) ON p.name = a.name AND p.xtype = 'PK'
WHERE (OBJECTPROPERTY(a.id, N'IsUserTable') = 1) AND (OBJECTPROPERTY(a.id, 
      N'IsMSShipped') = 0) AND (INDEXPROPERTY(a.id, a.name, 'IsAutoStatistics') = 0)
ORDER BY c.name, a.name, b.keyno
";

                        string str_表视图函数存储过程触发器主键外键约束规则 = @"
SELECT DISTINCT @@SERVERNAME AS 服务器,DB_NAME() AS 数据库,
      isnull(p.name,'') AS 父对象, o.xtype, 
      CASE o.xtype WHEN 'C' THEN 'CHECK 约束' WHEN 'D' THEN '默认值或DEFAULT约束'
       WHEN 'F' THEN 'FOREIGNKEY约束' WHEN 'L' THEN '日志' WHEN 'FN' THEN '标量函数'
       WHEN 'IF' THEN '内嵌表函数' WHEN 'P' THEN '存储过程' WHEN 'PK' THEN 'PRIMARYKEY约束'
       WHEN 'RF' THEN '复制筛选存储过程' WHEN 'S' THEN '系统表' WHEN 'TF' THEN '表函数'
       WHEN 'TR' THEN '触发器' WHEN 'U' THEN '用户表' WHEN 'UQ' THEN 'UNIQUE 约束'
       WHEN 'V' THEN '视图' WHEN 'X' THEN '扩展存储过程' WHEN 'R' THEN '规则' ELSE NULL
       END AS 类型, o.name AS 对象名, o.crdate AS 创建时间, o.refdate AS 更改时间, 
      c.text AS 声明语句,
      GETDATE() AS 采集时间
FROM dbo.sysobjects o with(nolock) Left JOIN
      dbo.sysobjects p with(nolock)  ON o.parent_obj = p.id LEFT OUTER JOIN
      dbo.syscomments c with(nolock)   ON o.id = c.id
WHERE --(o.xtype IN ('C','D','F','PK','UQ','L','FN','IF','TF','TR','P','R','RF','X','S','U','V')) AND 
      (OBJECTPROPERTY(o.id, N'IsMSShipped') = 0) AND (isnull(p.name,'') <> N'dtproperties')
ORDER BY o.xtype DESC 
    
";


                        string str_取本机已建立的链接服务器 = @"
SELECT @@servername AS SeverName,s.name linkedServerName,
       s.data_source linkedserver_source,
       s.is_linked,
       s.modify_date,
       ll.remote_name,
       ll.local_principal_id,
       ll.uses_self_credential,
       p.name localLoginName,
       GETDATE() AS CollecterDate
FROM   sys.Linked_logins ll with(nolock) 
       INNER JOIN sys.servers s with(nolock) 
            ON  s.server_id = ll.server_id
       LEFT JOIN sys.server_principals p with(nolock) 
            ON  p.principal_id = ll.local_principal_id
WHERE  s.is_linked = 1
";

                        DataTable dt_获取数据库中所有表的字段属性 = conn_DB.GetDataTable(str_获取数据库中所有表的字段属性, new string[0]);
                        DataTable dt_显示当前数据库中用户表的记录数量及大小 = conn_DB.GetDataTable(str_显示当前数据库中用户表的记录数量及大小, new string[0]);
                        DataTable dt_查询所有表的索引 = conn_DB.GetDataTable(str_查询所有表的索引, new string[0]);
                        DataTable dt_表视图函数存储过程触发器主键外键约束规则 = conn_DB.GetDataTable(str_表视图函数存储过程触发器主键外键约束规则, new string[0]);
                        DataTable dt_取本机已建立的链接服务器 = conn_DB.GetDataTable(str_取本机已建立的链接服务器, new string[0]);

                        DataTable dt_数据库名 = dt_获取数据库中所有表的字段属性.DefaultView.ToTable(true, new string[1] { "数据库名" });
                        DataTable dt_DBInfo = new DataTable();
                        if(dt_数据库名.Rows.Count>0)
                        {
                            string str_DBInfo = @"

     SELECT @@servername AS ServerName,
            DB_NAME() AS DBName,
            type_desc,
            name,
            physical_name,
            size,
            growth,
            GETDATE() AS CollecterDate
     FROM   " + dt_数据库名.Rows[0][0].ToString() + @".sys.database_files with(nolock) 
            ";
                            dt_DBInfo = conn_DB.GetDataTable(str_DBInfo, new string[0]);
                        }

                        ArrayList listTable = new ArrayList();
                        listTable.Add("TableDict");
                        listTable.Add("TableSize");
                        listTable.Add("DBInfo");
                        listTable.Add("TableIndex");
                        listTable.Add("DBOtherInfo");
                        listTable.Add("LinkServers");

                        //conn.ConnOpen();
                        conn.BeginTransaction();
                        try
                        {
                            conn.TableLock(listTable);


                            if (dt_DBInfo.Rows.Count > 0)
                            {
                                conn.InsertBYSQLBC("DBInfo", dt_DBInfo);
                            }



                            conn.InsertBYSQLBC("TableDict", dt_获取数据库中所有表的字段属性);
                            conn.InsertBYSQLBC("TableSize", dt_显示当前数据库中用户表的记录数量及大小);
                            conn.InsertBYSQLBC("TableIndex", dt_查询所有表的索引);
                            conn.InsertBYSQLBC("DBOtherInfo", dt_表视图函数存储过程触发器主键外键约束规则);
                            conn.InsertBYSQLBC("LinkServers", dt_取本机已建立的链接服务器);

                            conn.CommitTransaction();
                            //conn.ConnClose();

                        }
                        catch
                        {

                            conn.RollbackTransaction();
                        }

                    }

                }
            }

            return true;
        }
        public bool Execute()
        {
            string strEnv_ID = "";
            string strEnv_SN = "HZY_CMT";

            Dbconn conn_HZY_SBS = new Dbconn("F22GP_ForSalesPlan");

            DataSet ds = conn_HZY_SBS.GetDataSet(
                @" SELECT   
                                --98 AS Env_ID ,
                                NULL AS VexSSONewID ,
                                b.userid AS App_UserName ,
                                RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5', CONVERT(VARCHAR(100), b.password))), 32) AS App_Password ,
                                b.password AS App_PasswordSrc ,
                                CASE WHEN b.dptype <> 0 THEN ISNULL(a.depotid,'') + '_' + d_name ELSE b.username END  AS App_UserName_CN ,
                                GETDATE() Chang_Password_Time ,
                                1 Checked ,
                                'system' Check_User ,
                                GETDATE() Check_Time ,
                                GETDATE() Createtime ,
                                GETDATE() Updatetime,
                                0 as oprationFlag
                        FROM    
                                j_user b
                                LEFT JOIN j_depot a ON a.depotid = b.depotid
                     ");

            Dbconn connMDM = new Dbconn("VexSSO");

            try
            {

                ArrayList tableList = new ArrayList();
                connMDM.BeginTransaction();
                tableList.Add("MDM_System_User");
                connMDM.TableLock(tableList);

                strEnv_ID = connMDM.GetDataTableFirstValue("SELECT [Env_ID]  FROM [MDM_System_Env]  WHERE Env_SN='" + strEnv_SN + "'").ToString();
                DataTable dtMDM = connMDM.GetDataTable(@"
                                                        SELECT [App_UserID]
                                                              ,[Env_ID]
                                                              ,[VexSSONewID]
                                                              ,[App_UserName]
                                                              ,[App_Password]
                                                              ,[App_PasswordSrc]
                                                              ,[App_UserName_CN]
                                                              ,[Chang_Password_Time]
                                                              ,[Checked]
                                                              ,[Check_User]
                                                              ,[Check_Time]
                                                              ,[Createtime]
                                                              ,[Updatetime]
                                                          FROM [dbo].[MDM_System_User]
                                                          WHERE Env_ID='" + strEnv_ID + @"'
                                                        ");


                DataTable dtMDMUpdate = dtMDM.Clone();
                DataTable dtMDMInsert = dtMDM.Clone();
                DataTable dtMDMDelete = dtMDM.Clone();

                for (int i = 0; i < dtMDM.Rows.Count; i++)
                {
                    string strApp_UserName = dtMDM.Rows[i]["App_UserName"].ToString();

                    DataRow[] dr = ds.Tables[0].Select("App_UserName='******'");
                    if (dr.Length > 0)
                    {
                        dtMDM.Rows[i]["App_Password"] = dr[0]["App_Password"];
                        dtMDM.Rows[i]["App_PasswordSrc"] = dr[0]["App_PasswordSrc"];
                        dtMDM.Rows[i]["App_UserName_CN"] = dr[0]["App_UserName_CN"];

                        dtMDMUpdate.ImportRow(dtMDM.Rows[i]);
                        dr[0]["oprationFlag"] = "1";
                    }
                    else
                    {
                        dtMDMDelete.ImportRow(dtMDM.Rows[i]);
                    }
                }

                DataRow[] drInsert = ds.Tables[0].Select("oprationFlag=0");
                for (int i = 0; i < drInsert.Length; i++)
                {
                    DataRow dr = dtMDMInsert.NewRow();
                    dr["Env_ID"] = strEnv_ID;
                    dr["VexSSONewID"] = drInsert[i]["VexSSONewID"];
                    dr["App_UserName"] = drInsert[i]["App_UserName"];
                    dr["App_Password"] = drInsert[i]["App_Password"];
                    dr["App_PasswordSrc"] = drInsert[i]["App_PasswordSrc"];
                    dr["App_UserName_CN"] = drInsert[i]["App_UserName_CN"];
                    dr["Chang_Password_Time"] = drInsert[i]["Chang_Password_Time"];
                    dr["Checked"] = drInsert[i]["Checked"];
                    dr["Check_User"] = drInsert[i]["Check_User"];
                    dr["Check_Time"] = drInsert[i]["Check_Time"];
                    dr["Createtime"] = drInsert[i]["Createtime"];
                    dr["Updatetime"] = drInsert[i]["Updatetime"];
                    dtMDMInsert.Rows.Add(dr);
                }

                if (dtMDMDelete.Rows.Count > 0)
                {
                    for (int i = 0; i < dtMDMDelete.Rows.Count; i++)
                    {
                        string strWhere = "App_UserID='" + dtMDMDelete.Rows[i]["App_UserID"] + "'";
                        connMDM.Delete("MDM_System_User", strWhere);
                    }
                }


                if (dtMDMUpdate.Rows.Count > 0)
                {
                    ArrayList listKey = new ArrayList();
                    listKey.Add("App_UserID");
                    connMDM.Update("MDM_System_User", dtMDMUpdate, listKey);
                }

                if (dtMDMInsert.Rows.Count > 0)
                {
                    dtMDMUpdate.Columns.Remove("App_UserID");
                    connMDM.InsertBYSQLBC("MDM_System_User", dtMDMInsert);
                }
                connMDM.CommitTransaction();
                return true;
            }
            catch
            {
                connMDM.RollbackTransaction();
                throw;
            }
        }
        public bool Execute()
        {
            string strEnv_ID = "";
            string strEnv_SN = "HZY_SCM";

            Dbconn conn_PLM_AS = new Dbconn("ERP_PROD");
            DataSet ds = conn_PLM_AS.GetDataSet(
                @"  
                SELECT  NULL AS VexSSONewID ,
                        IDSUNO AS App_UserName ,
                        RIGHT(sys.fn_VarBinToHexStr(HASHBYTES('MD5',
                                                                CONVERT(VARCHAR(100), '123456a'))),
                                32) AS App_PasswordSrc ,
                        RIGHT(sys.fn_VarBinToHexStr(HASHBYTES('MD5',
                                                                CONVERT(VARCHAR(100), '123456a'))),
                                32) AS App_Password ,
                        IDSUNM AS App_UserName_CN ,
                        GETDATE() Chang_Password_Time ,
                        1 Checked ,
                        'system' Check_User ,
                        GETDATE() Check_Time ,
                        GETDATE() Createtime ,
                        GETDATE() Updatetime ,
                        0 AS oprationFlag
                FROM    CIDMAS
                WHERE   IDCONO = 100
                        AND IDSTAT = 20");

            Dbconn connMDM = new Dbconn("VexSSO");

            try
            {
                ArrayList tableList = new ArrayList();
                connMDM.BeginTransaction();
                tableList.Add("MDM_System_User");
                connMDM.TableLock(tableList);

                strEnv_ID = connMDM.GetDataTableFirstValue("SELECT [Env_ID]  FROM [MDM_System_Env]  WHERE Env_SN='" + strEnv_SN + "'").ToString();
                DataTable dtMDM = connMDM.GetDataTable(@"
                                                        SELECT [App_UserID]
                                                              ,[Env_ID]
                                                              ,[VexSSONewID]
                                                              ,[App_UserName]
                                                              ,[App_Password]
                                                              ,[App_PasswordSrc]
                                                              ,[App_UserName_CN]
                                                              ,[Chang_Password_Time]
                                                              ,[Checked]
                                                              ,[Check_User]
                                                              ,[Check_Time]
                                                              ,[Createtime]
                                                              ,[Updatetime]
                                                          FROM [dbo].[MDM_System_User]
                                                          WHERE Env_ID='" + strEnv_ID + @"'
                                                        ");


                DataTable dtMDMUpdate = dtMDM.Clone();
                DataTable dtMDMInsert = dtMDM.Clone();
                DataTable dtMDMDelete = dtMDM.Clone();

                for (int i = 0; i < dtMDM.Rows.Count; i++)
                {
                    string strApp_UserName = dtMDM.Rows[i]["App_UserName"].ToString();

                    DataRow[] dr = ds.Tables[0].Select("App_UserName='******'");
                    if (dr.Length > 0)
                    {
                        //只修改供应商名称不修改帐号密码
                        //dtMDM.Rows[i]["App_Password"] = dr[0]["App_Password"];
                        //dtMDM.Rows[i]["App_PasswordSrc"] = dr[0]["App_PasswordSrc"];
                        dtMDM.Rows[i]["App_UserName_CN"] = dr[0]["App_UserName_CN"];

                        dtMDMUpdate.ImportRow(dtMDM.Rows[i]);
                        dr[0]["oprationFlag"] = "1";
                    }
                    else
                    {
                        dtMDMDelete.ImportRow(dtMDM.Rows[i]);
                    }
                }

                DataRow[] drInsert = ds.Tables[0].Select("oprationFlag=0");
                for (int i = 0; i < drInsert.Length; i++)
                {
                    DataRow dr = dtMDMInsert.NewRow();
                    dr["Env_ID"] = strEnv_ID;
                    dr["VexSSONewID"] = drInsert[i]["VexSSONewID"];
                    dr["App_UserName"] = drInsert[i]["App_UserName"];
                    dr["App_Password"] = drInsert[i]["App_Password"];
                    dr["App_PasswordSrc"] = drInsert[i]["App_PasswordSrc"];
                    dr["App_UserName_CN"] = drInsert[i]["App_UserName_CN"];
                    dr["Chang_Password_Time"] = drInsert[i]["Chang_Password_Time"];
                    dr["Checked"] = drInsert[i]["Checked"];
                    dr["Check_User"] = drInsert[i]["Check_User"];
                    dr["Check_Time"] = drInsert[i]["Check_Time"];
                    dr["Createtime"] = drInsert[i]["Createtime"];
                    dr["Updatetime"] = drInsert[i]["Updatetime"];
                    dtMDMInsert.Rows.Add(dr);
                }

                if (dtMDMDelete.Rows.Count > 0)
                {
                    for (int i = 0; i < dtMDMDelete.Rows.Count; i++)
                    {
                        string strWhere = "App_UserID='" + dtMDMDelete.Rows[i]["App_UserID"] + "'";
                        connMDM.Delete("MDM_System_User", strWhere);
                    }
                }


                if (dtMDMUpdate.Rows.Count > 0)
                {
                    ArrayList listKey = new ArrayList();
                    listKey.Add("App_UserID");
                    connMDM.Update("MDM_System_User", dtMDMUpdate, listKey);
                }

                if (dtMDMInsert.Rows.Count > 0)
                {
                    dtMDMUpdate.Columns.Remove("App_UserID");
                    connMDM.InsertBYSQLBC("MDM_System_User", dtMDMInsert);
                }
                connMDM.CommitTransaction();
                return true;
            }
            catch
            {
                connMDM.RollbackTransaction();
                throw;
            }
        }