Esempio n. 1
0
        private void NewFixJudge()
        {
            DataRow drRow = this.dt_Return.NewRow();
            //获取维修单号
            string wxno 
                = this.dtList.Rows[0]["WXNo"].ToString();
            string warehouse
                = this.dtList.Rows[0]["Warehouse"].ToString();

            wxno = FilterSpecial(wxno);
            warehouse = FilterSpecial(warehouse);

            string selectMain
                = @"SELECT [ID] 
                        ,[WXNo]
                        ,[DepotId]
                        ,[CreateUser]
                        ,[SKU]
                        ,[Status]
                        ,[WarehouseNo]
                        ,[ModifyTime]
                        ,[ModifyUser]
                    FROM [dbo].[SPWX_Main] WITH(NOLOCK)
                    WHERE [Status] = '20' AND [WXNo] = @Param0 ";

            //创建连接对象
            DBHandle dbh = new DBHandle("SPWX");
            
            //获取主表状态
            DataTable dtMain 
                = dbh.GetData(selectMain,new object[]{wxno});

            //判断有无初判数据
            if (dtMain.Rows.Count > 0)
            {
                //获取交易表表头
                DataTable dtHist = dbh.GetTabHead("[dbo].[SPWX_Hist]");

                DataRow dr = dtHist.NewRow();
                dr["WXNo"] = wxno;
                dr["BeforeStatus"] = dtMain.Rows[0]["Status"].ToString();
                dr["AfterStatus"] = "25";
                dr["Content"] = "操作内容:完成初判";
                dr["ModifyUser"] = base.m_hzyMessage.User_Name;

                dtHist.Rows.Add(dr);
                //修改主表状态,修改人
                dtMain.Rows[0]["Status"] = "25";
                dtMain.Rows[0]["ModifyUser"] = base.m_hzyMessage.User_Name;
                dtMain.Rows[0]["ModifyTime"] = timeNow.ToString();

                //获取维修价格和时间
                string value
                    = this.dtList.Rows[0]["FirstPhen"].ToString();
                value = FilterSpecial(value);

                DataTable dtMD = GetMoneyDay(value);

                //新插入表
                this.dtList.Columns.Add("CreateUser");
                this.dtList.Columns.Add("ModifyUser");


                this.dtList.Rows[0]["FixNeedTime"]
                    = dtMD.Rows[0]["Day"].ToString();
                this.dtList.Rows[0]["FixNeedMoney"]
                    = dtMD.Rows[0]["Money"].ToString();
                this.dtList.Rows[0]["CreateUser"]
                        = base.m_hzyMessage.User_Name;
                this.dtList.Rows[0]["ModifyUser"]
                        = base.m_hzyMessage.User_Name;

                //调用退仓单

                if (warehouse.Length > 0)
                {
                    string DepotId = dtMain.Rows[0]["DepotId"].ToString();
                    string CreateUser = dtMain.Rows[0]["CreateUser"].ToString();
                    string sku = dtMain.Rows[0]["SKU"].ToString();
                    string sendUser = base.m_hzyMessage.User_Name;
                    string WarehouseNo = dtMain.Rows[0]["WarehouseNo"].ToString();

                    DBHandle dbhGP = new DBHandle("F22GP");

                    object[] paramObj = new object[4];

                    object[] paramVal = new object[4];

                    paramObj[0] = SParam.InputFormat;
                    paramObj[1] = SParam.OutputFormat;
                    paramObj[2] = SParam.OutputContentType;
                    paramObj[3] = SParam.ConditionStr;

                    paramVal[0] = "AML";
                    paramVal[1] = "DB";
                    paramVal[2] = "RS";
                    paramVal[3] = @"【操作类型,NEW】【实体,发货】
                        【新增内容,发货店铺ID,收货店铺ID,装箱号,款号,款式编号,颜色,尺码,退货数量,成本,
                            原价,现价,结算价,折扣,登记人,发货操作员,收货操作员】
                        【条件内容,《N》发货店铺ID,《N》收货店铺ID,《N》装箱号,《N》款号,《N》款式编号,
                            《N》颜色,《N》尺码,《N》退货数量,《N》成本,《N》原价,《N》现价,《N》结算价,《N》折扣,
                            《N》登记人,《N》发货操作员,《N》收货操作员 】
                        【《N》维修单号," + wxno + "】【《N》发货店铺ID," + DepotId + "】【《N》收货店铺ID," + WarehouseNo + @"】
                        【《N》装箱号," + sendUser + "】【《N》款号," + sku + @"】【《N》款式编号,】【《N》颜色,】
                        【《N》尺码,】【《N》退货数量,1】【《N》成本,0】【《N》原价,0】【《N》现价,0】【《N》结算价,0】
                        【《N》折扣,0】【《N》登记人," + sendUser + "】【《N》发货操作员," + sendUser + "】【《N》收货操作员,】";
                    DataTable dtRtn
                        = dbhGP.GetDataBySP("[API_Bill].[Thd_Info]", paramObj, paramVal);

                    if (dtRtn != null)
                    {
                        if (dtRtn.Rows.Count > 0)
                        {
                            string result = dtRtn.Rows[0]["FLAG"].ToString();

                            if (result.ToUpper() == "TRUE")
                            {
                                string returnNo = dtRtn.Rows[0]["outindentid"].ToString();
                                this.dtList.Columns.Add("ReturnNo");
                                this.dtList.Rows[0]["ReturnNo"] = returnNo;
                                //调用收货的过程
                                paramVal[3] = @"【操作类型,NEW】【实体,收货】
                                    【新增内容,退货单号,发货店铺ID,收货店铺ID,装箱号,款号,款式编号,颜色,尺码,退货数量,成本,
                                        原价,现价,结算价,折扣,登记人,发货操作员,收货操作员】
                                    【条件内容,《N》退货单号,《N》发货店铺ID,《N》收货店铺ID,《N》装箱号,《N》款号,《N》款式编号,
                                        《N》颜色,《N》尺码,《N》退货数量,《N》成本,《N》原价,《N》现价,《N》结算价,《N》折扣,《N》登记人,
                                        《N》发货操作员,《N》收货操作员 】【《N》退货单号," + returnNo + "】【《N》发货店铺ID," + DepotId + @"】
                                        【《N》收货店铺ID," + WarehouseNo + "】【《N》装箱号," + sendUser + "】【《N》款号," + sku + @"】【《N》款式编号,】
                                        【《N》颜色,】【《N》尺码,】【《N》退货数量,1】【《N》成本,0】【《N》原价,0】【《N》现价,0】
                                        【《N》结算价,0】【《N》折扣,0】【《N》登记人," + CreateUser + "】【《N》发货操作员,】【《N》收货操作员," + sendUser + "】";
                                DataTable dtClt
                                    = dbhGP.GetDataBySP("[API_Bill].[Thd_Info]", paramObj, paramVal);
                                if (dtClt != null)
                                {
                                    if (dtClt.Rows.Count > 0)
                                    {
                                        if (dtClt.Rows[0]["FLAG"].ToString().ToUpper() == "TRUE")
                                        {
                                            DataTable dtHead = this.dtList.Copy();
                                            dtHead.TableName = "[dbo].[SPWX_Headquarters]";
                                            dtMain.TableName = "[dbo].[SPWX_Main]";
                                            dtHist.TableName = "[dbo].[SPWX_Hist]";

                                            DataSet ds = new DataSet();
                                            ds.Tables.Add(dtHead);
                                            ds.Tables.Add(dtMain);
                                            ds.Tables.Add(dtHist);

                                            this.bRst = dbh.UpdateDB("ID", ds);

                                            if (this.bRst)
                                            {
                                                drRow["result"] = true;
                                                drRow["message"] = "提交成功";
                                            }
                                            else
                                            {
                                                drRow["result"] = false;
                                                drRow["message"] = "提交失败";
                                            };
                                        }
                                        else
                                        {
                                            string msg = dtRtn.Rows[0]["message"].ToString();
                                            drRow["result"] = false;
                                            drRow["message"] = msg;
                                        };
                                    }
                                    else
                                    {
                                        drRow["result"] = false;
                                        drRow["message"] = "收货单生成失败,请联系信息管理部。";
                                    };
                                }
                                else
                                {
                                    drRow["result"] = false;
                                    drRow["message"] = "收货单生成失败,请联系信息管理部。";
                                };

                            }
                            else
                            {
                                string msg = dtRtn.Rows[0]["message"].ToString();
                                drRow["result"] = false;
                                drRow["message"] = msg;
                            };
                        }
                        else
                        {
                            drRow["result"] = false;
                            drRow["message"] = "退货单生成失败,请联系信息管理部。";
                        };
                    }
                    else
                    {
                        drRow["result"] = false;
                        drRow["message"] = "退货单生成失败,请联系信息管理部。";
                    };
                }
                else
                {
                    DataTable dtHead = this.dtList.Copy();
                    dtHead.TableName = "[dbo].[SPWX_Headquarters]";
                    dtMain.TableName = "[dbo].[SPWX_Main]";
                    dtHist.TableName = "[dbo].[SPWX_Hist]";

                    DataSet ds = new DataSet();
                    ds.Tables.Add(dtHead);
                    ds.Tables.Add(dtMain);
                    ds.Tables.Add(dtHist);

                    this.bRst = dbh.UpdateDB("ID", ds);

                    if (this.bRst)
                    {
                        drRow["result"] = true;
                        drRow["message"] = "提交成功";
                    }
                    else
                    {
                        drRow["result"] = false;
                        drRow["message"] = "提交失败";
                    };
                };
            }
            else 
            {
                drRow["result"] = false;
                drRow["message"] = "在初判表中已经无法找到该维修单号,请确认。";
            };
            
            this.dt_Return.Rows.Add(drRow);

            this.ds_Return.Tables.Add(this.dt_Return);
        }
Esempio n. 2
0
        //HWA

        #region 检查快递单号

        private void CheckExpNo()
        {
            DataTable dtChk = this.dtList.Copy();
            DataTable dtRst = new DataTable();
            string ExpNo = "";
            string WxNo = "";

            if (dtChk.Columns.Contains("ExpNo"))
            {
                ExpNo = dtChk.Rows[0]["ExpNo"].ToString();
                ExpNo = FilterSpecial(ExpNo);
                ExpNo = ExpNo.ToUpper();
            }
            else if (dtChk.Columns.Contains("WxNo"))
            {
                WxNo = dtChk.Rows[0]["WxNo"].ToString();
                WxNo = FilterSpecial(WxNo);
            };

            string DepotId
                = base.m_hzyMessage.User_Name_CN.Split('_')[0];
            string select = "";

            bool b = Convert.ToChar(DepotId.Substring(0, 1)) <= 'Z';

            if (b)//店铺
            {
                if (ExpNo.Length > 0)
                {
                    select = @"SELECT T1.[ID]
                            ,T1.[WXNo]
                            ,T1.[Status]
                            ,T1.[ModifyTime]
                            ,T1.[ModifyUser]
                        FROM [dbo].[SPWX_Main] T1
                        LEFT JOIN [dbo].[SPWX_Headquarters] T2
                        ON T1.[WXNo] = T2.[WXNo]
                        WHERE T1.[Status] = 45 AND T1.[DepotId] = '"
                            + DepotId + "' AND T2.[ExpNo] = @Param0";
                }
                else if (WxNo.Length > 0)
                {
                    select = @"SELECT T1.[ID]
                            ,T1.[WXNo]
                            ,T1.[Status]
                            ,T1.[ModifyTime]
                            ,T1.[ModifyUser]
                        FROM [dbo].[SPWX_Main] T1
                        LEFT JOIN [dbo].[SPWX_Headquarters] T2
                        ON T1.[WXNo] = T2.[WXNo]
                        WHERE T1.[Status] = 45 AND T1.[DepotId] = '"
                                + DepotId + "' AND T1.[WxNo] = @Param0";
                };
            }
            else
            {
                if (ExpNo.Length > 0)
                {
                    select = @"SELECT [ID]
                            ,[WXNo]
                            ,[Status]
                            ,[ModifyTime]
                            ,[ModifyUser]
                        FROM [dbo].[SPWX_Main]
                        WHERE [Status] = '16' 
                        AND [ExpressNo] = @Param0";
                }
                else if(WxNo.Length >0)
                {
                    select = @"SELECT [ID]
                            ,[WXNo]
                            ,[Status]
                            ,[ModifyTime]
                            ,[ModifyUser]
                        FROM [dbo].[SPWX_Main]
                        WHERE [Status] = '16' 
                        AND [WXNo] = @Param0";
                };
                 
            };

            DBHandle dbh = new DBHandle("SPWX");
            if (ExpNo.Length > 0)
            {
                dtRst = dbh.GetData(select, new object[1] { ExpNo });
            }
            else if (WxNo.Length > 0)
            {
                dtRst = dbh.GetData(select, new object[1] { WxNo });
            };

            if (dtRst.Rows.Count > 0)
            {
                DataTable dtHist 
                    = dbh.GetTabHead("[dbo].[SPWX_Hist]");


                for (int i = 0; i < dtRst.Rows.Count; i++)
                {
                    //交易表
                    DataRow drHist = dtHist.NewRow();

                    drHist["WXNo"]
                        = dtRst.Rows[i]["WXNo"].ToString();
                    drHist["BeforeStatus"]
                        = dtRst.Rows[i]["Status"].ToString();
                    if (b)
                    {
                        drHist["AfterStatus"] = "50";
                        drHist["Content"] = "操作内容:店铺已经收货";
                    }
                    else
                    {
                        drHist["AfterStatus"] = "20";
                        drHist["Content"] = "操作内容:维修单已经收货";
                    };
                        
                    drHist["ModifyTime"] = this.timeNow;
                    drHist["ModifyUser"] 
                        = base.m_hzyMessage.User_Name;

                    dtHist.Rows.Add(drHist);

                    //主表
                    if (b)
                    {
                        dtRst.Rows[i]["Status"] = "50";
                    }
                    else
                    {
                        dtRst.Rows[i]["Status"] = "20";
                    };

                    dtRst.Rows[i]["ModifyTime"] = this.timeNow;
                    dtRst.Rows[i]["ModifyUser"] 
                        = base.m_hzyMessage.User_Name;
                };
                dtRst.TableName = "[dbo].[SPWX_Main]";
                dtHist.TableName = "[dbo].[SPWX_Hist]";

                DataSet ds = new DataSet();
                ds.Tables.Add(dtRst);
                ds.Tables.Add(dtHist);

                this.bRst = dbh.UpdateDB("ID", ds);
                
            };

            DataRow drRow = this.dt_Return.NewRow();

            if (this.bRst)
            //if (dt.Rows.Count >0)
            {
                drRow["result"] = true;
                drRow["message"] = "成功";
            }
            else
            {
                drRow["result"] = false;
                drRow["message"] = "失败";
            };

            this.dt_Return.Rows.Add(drRow);

            this.ds_Return.Tables.Add(this.dt_Return);

        }
Esempio n. 3
0
        private void CrtNewWX()
        {
            DBHandle dbh = new DBHandle("SPWX");

            DataRow drRow = this.dt_Return.NewRow();

            DataTable dtCp = this.dtList.Copy();

            if (dtCp.Rows[0]["ExpressNo"].ToString().Length > 0)
            {
                dtCp.Rows[0]["ExpressNo"]
                    = dtCp.Rows[0]["ExpressNo"].ToString().ToUpper();
            };

            DataTable dtHist = dbh.GetData(
                "SELECT TOP 0 * FROM [dbo].[SPWX_Hist] WITH(NOLOCK)", 
                new object[] { });

            DataRow dr = dtHist.NewRow();

            dtCp.Columns.Add("WXNo");
            dtCp.Columns.Add("Status");
            dtCp.Columns.Add("BackDate");
            dtCp.Columns.Add("WxStatus");
            dtCp.Columns.Add("CreateUser");
            dtCp.Columns.Add("ModifyUser");

            int iMax = getMaxWXNo();

            if (iMax != 0)
            {
                dtCp.Rows[0]["WXNo"] = iMax.ToString();
                dtCp.Rows[0]["Status"] = "16";
                dtCp.Rows[0]["BackDate"] = this.timeNow;
                dtCp.Rows[0]["CreateUser"] = base.m_hzyMessage.User_Name;
                dtCp.Rows[0]["ModifyUser"] = base.m_hzyMessage.User_Name;
                if (dtCp.Columns.Contains("VIPID"))
                {
                    dtCp.Rows[0]["WxStatus"] = "client";
                }
                else
                {
                    if (dtCp.Columns.Contains("VIPName"))
                    {
                        if (dtCp.Rows[0]["VIPName"].ToString().Length > 0)
                        {
                            dtCp.Rows[0]["WxStatus"] = "client";
                        }
                        else
                        {
                            dtCp.Rows[0]["WxStatus"] = "unsell";
                        };
                    }
                    else 
                    {
                        dtCp.Rows[0]["WxStatus"] = "unsell";
                    };
                    
                };

                //历史记录
                dr["WXNo"] = iMax.ToString();
                dr["BeforeStatus"] = "15";
                dr["AfterStatus"] = "16";
                dr["Content"] = "操作内容:创建维修单,并发货.";
                dr["ModifyUser"] = base.m_hzyMessage.User_Name;

                dtHist.Rows.Add(dr);
                
                dtCp.TableName = "[dbo].[SPWX_Main]";
                dtHist.TableName = "[dbo].[SPWX_Hist]";

                DataSet ds = new DataSet();

                ds.Tables.Add(dtCp);
                ds.Tables.Add(dtHist);
                this.bRst = dbh.UpdateDB("ID", ds);

                

                if (this.bRst)
                {
                    drRow["result"] = true;
                    drRow["message"] = "提交成功";
                }
                else
                {
                    drRow["result"] = false;
                    drRow["message"] = "提交失败";
                };
            }
            else 
            {
                drRow["result"] = false;
                drRow["message"] = "提交失败";
            };

            this.dt_Return.Rows.Add(drRow);

            this.ds_Return.Tables.Add(this.dt_Return);
            
        }
Esempio n. 4
0
        private void SaveExp()
        {
            DataRow drRow = this.dt_Return.NewRow();
            DataTable dt = this.dtList.Copy();

            string wxno = "";
            
            int count = dt.Rows.Count;

            object[] o = new object[count];

            for (int i = 0; i < count; i++)
            { 
                if(i !=count-1)
                {
                    wxno += "@Param" + i + ",";
                    
                }
                else if (i == count - 1)
                {
                    wxno += "@Param" + i;
                   
                };
                o[i] = dt.Rows[i]["Wxno"].ToString();
            };

            string headp = @"
                    SELECT [Id]
                          ,[ExpName]
                          ,[ExpNo]
                          ,[ModifyUser]
                          ,[ModifyTime]
                      FROM [dbo].[SPWX_Headquarters] WITH(NOLOCK)
                      WHERE WXNO in (" + wxno + ")";
            string main = @"
                    SELECT [ID]
                        ,[Wxno]
                        ,[Status]
                        ,[ModifyTime]
                        ,[ModifyUser]
                    FROM [dbo].[SPWX_Main] WITH(NOLOCK)
                    WHERE ([Status] = 40 or [Status] = 26) 
                    AND WXNO IN ("+wxno+")";
            string hist = @"
                    SELECT TOP 0 * FROM [dbo].[SPWX_Hist] WITH(NOLOCK)";
            try
            {
                DBHandle dbh = new DBHandle("SPWX");

                DataTable dtHp = dbh.GetData(headp, o);
                DataTable dtMa = dbh.GetData(main, o);
                DataTable dtHi = dbh.GetData(hist, new object[0]);


                if (dtHi != null && dtHp != null && dtMa != null)
                {
                    //
                    if(dtHp.Rows.Count == dt.Rows.Count)
                    {
                        for (int i = 0; i < dtHp.Rows.Count; i++)
                        {
                            dtHp.Rows[i]["ExpName"] = dt.Rows[i]["ExpName"];
                            dtHp.Rows[i]["ExpNo"] = dt.Rows[i]["ExpNo"].ToString().ToUpper();
                            dtHp.Rows[i]["ModifyUser"] = base.hzyMessage.User_Name;
                            dtHp.Rows[i]["ModifyTime"] = timeNow;
                        };
                    };

                    //
                    if (dtMa.Rows.Count == dt.Rows.Count)
                    {
                        for (int i = 0; i < dtMa.Rows.Count; i++)
                        {
                            DataRow dr = dtHi.NewRow();

                            dr["WXNo"] = dtMa.Rows[i]["Wxno"];
                            dr["BeforeStatus"] = dtMa.Rows[i]["Status"];
                            dr["AfterStatus"] = "45";
                            dr["Content"] = "总部已经发货";
                            dr["ModifyTime"] = timeNow;
                            dr["ModifyUser"] = base.hzyMessage.User_Name;

                            dtHi.Rows.Add(dr);

                            dtMa.Rows[i]["Status"] = "45";
                            dtMa.Rows[i]["ModifyUser"] = base.hzyMessage.User_Name;
                            dtMa.Rows[i]["ModifyTime"] = timeNow;
                        };
                    };

                    dtHp.TableName = "[dbo].[SPWX_Headquarters]";
                    dtMa.TableName = "[dbo].[SPWX_Main]";
                    dtHi.TableName = "[dbo].[SPWX_Hist]";

                    DataSet ds = new DataSet();
                    ds.Tables.Add(dtHp);
                    ds.Tables.Add(dtMa);
                    ds.Tables.Add(dtHi);

                    this.bRst = dbh.UpdateDB("ID", ds);
                    

                    if (this.bRst)
                    {
                        drRow["result"] = true;
                        drRow["message"] = "提交成功";
                    }
                    else
                    {
                        drRow["result"] = false;
                        drRow["message"] = "提交失败";
                    };
                };
            }
            catch (Exception ex)
            {
                drRow["result"] = false;
                drRow["message"] = ex.Message;
                this.dt_Return.Rows.Add(drRow);
                this.ds_Return.Tables.Add(this.dt_Return);
                throw;
            };

            this.dt_Return.Rows.Add(drRow);

            this.ds_Return.Tables.Add(this.dt_Return);
        }
Esempio n. 5
0
        private void UpdateFix()
        {
            string wxno 
                = this.dtList.Rows[0]["wxno"].ToString();
            string beforeSta = "";

            try
            {
                DBHandle dbh = new DBHandle("SPWX");

                string Headp = @"
                        SELECT * FROM 
                        [dbo].[SPWX_Headquarters] WITH(NOLOCK)
                        WHERE [WXNo] = @Param0";
                string Main = @"
                        SELECT [ID]
                              ,[Status]
                              ,[ModifyTime]
                              ,[ModifyUser]
                        FROM [dbo].[SPWX_Main] WITH(NOLOCK)
                        WHERE [WXNo] = @Param0";
                string Hist = @"
                        SELECT TOP 0 * FROM 
                        [dbo].[SPWX_Hist] WITH(NOLOCK)";

                DataTable dtHp
                    = dbh.GetData(Headp, new object[1] { wxno });
                DataTable dtMain
                    = dbh.GetData(Main, new object[1] { wxno });
                DataTable dtHi
                    = dbh.GetData(Hist, new object[0]);

                if (dtHp != null && dtMain != null && dtHi != null)
                {

                    if (dtHp.Rows.Count > 0)
                    {
                        dtHp.Rows[0]["FirstOrigin"] = this.dtList.Rows[0]["FirstOrigin"];
                        dtHp.Rows[0]["FirstQust"] = this.dtList.Rows[0]["FirstQust"];
                        dtHp.Rows[0]["FirstPhen"] = this.dtList.Rows[0]["FirstPhen"];
                        dtHp.Rows[0]["SecondOrigin"] = this.dtList.Rows[0]["SecondOrigin"];
                        dtHp.Rows[0]["SecondQust"] = this.dtList.Rows[0]["SecondQust"];
                        dtHp.Rows[0]["SecondPhen"] = this.dtList.Rows[0]["SecondPhen"];
                        dtHp.Rows[0]["FirstDecide"] = this.dtList.Rows[0]["FirstDecide"];
                        dtHp.Rows[0]["SecondDecide"] = this.dtList.Rows[0]["SecondDecide"];
                        dtHp.Rows[0]["ThirdDecide"] = this.dtList.Rows[0]["ThirdDecide"];
                        dtHp.Rows[0]["FixLength"] = this.dtList.Rows[0]["FixLength"];
                        //dtHp.Rows[0]["FixPlace"] = this.dtList.Rows[0]["FixPlace"];
                        dtHp.Rows[0]["SecFixLen"] = this.dtList.Rows[0]["SecFixLen"];
                        //dtHp.Rows[0]["SecFixPlace"] = this.dtList.Rows[0]["SecFixPlace"];
                        dtHp.Rows[0]["ModifyUser"] = base.m_hzyMessage.User_Name;
                        dtHp.Rows[0]["ModifyTime"] = timeNow;
                    };

                    if (dtMain.Rows.Count > 0)
                    {
                        dtMain.Rows[0]["ModifyTime"] = timeNow;
                        dtMain.Rows[0]["ModifyUser"] = base.m_hzyMessage.User_Name;

                        beforeSta = dtMain.Rows[0]["Status"].ToString();
                    };

                    DataRow dr = dtHi.NewRow();

                    dr["WXNo"] = wxno;
                    dr["BeforeStatus"] = beforeSta;
                    dr["AfterStatus"] = beforeSta;
                    dr["Content"] = "进行了维修再判定操作";
                    dr["ModifyTime"] = timeNow;
                    dr["ModifyUser"] = base.m_hzyMessage.User_Name;

                    dtHi.Rows.Add(dr);

                    if (dtHp.Rows.Count > 0
                        && dtHi.Rows.Count > 0
                        && dtMain.Rows.Count > 0)
                    {
                        dtHp.TableName = "[dbo].[SPWX_Headquarters]";
                        dtMain.TableName = "[dbo].[SPWX_Main]";
                        dtHi.TableName = "[dbo].[SPWX_Hist]";

                        DataSet ds = new DataSet();

                        ds.Tables.Add(dtHp);
                        ds.Tables.Add(dtMain);
                        ds.Tables.Add(dtHi);
                        this.bRst = dbh.UpdateDB("ID", ds);
                    };
                };

                DataRow drRow = this.dt_Return.NewRow();

                if (this.bRst)
                {
                    drRow["result"] = true;
                    drRow["message"] = "提交成功";
                }
                else{
                    drRow["result"] = false;
                    drRow["message"] = "提交失败";
                };

                this.dt_Return.Rows.Add(drRow);

                this.ds_Return.Tables.Add(this.dt_Return);
               
            }
            catch (Exception ex)
            {
                DataRow drRow = this.dt_Return.NewRow();
                drRow["result"] = false;
                drRow["message"] = ex.Message;

                this.dt_Return.Rows.Add(drRow);
                this.ds_Return.Tables.Add(this.dt_Return);
            };
        }
Esempio n. 6
0
        /// <summary>
        /// logic:
        /// 1.Update 'finish' field in table [dbo].[SPWX_Headquarters].
        /// 2.Update 'status' field in table [dbo].[SPWX_Main].
        /// 3.Insert history in [dbo.SPWX_Hist] Table.
        /// </summary>
        private void SaveFin()
        {

            DataRow drRow = this.dt_Return.NewRow();

            string beforeStatus = "";

            string wxno 
                = this.dtList.Rows[0]["Wxno"].ToString();

            string Headquarters = @"
                            SELECT [Id]
                                  ,[IsFinish]
                                  ,[FinishMan]
                                  ,[FinishDate]
                                  ,[FinishPoint]
                                  ,[FinishMoney]
                                  ,[ModifyUser]
                                  ,[ModifyTime]
                              FROM [dbo].[SPWX_Headquarters] WHIT(NOLOCK)
                              WHERE [WXNo] = @Param0";
            string Main = @"
                            SELECT [ID]
                                  ,[Status]
                                  ,[ModifyTime]
                                  ,[ModifyUser]
                              FROM [dbo].[SPWX_Main] WHIT(NOLOCK)
                              WHERE [WXNo] = @Param0";
            string Hist = @"
                            SELECT TOP 0 * FROM [dbo].[SPWX_Hist] WITH(NOLOCK)";

            try
            {
                DBHandle dbh = new DBHandle("SPWX");

                DataTable dtUp
                    = dbh.GetData(Headquarters, new object[1] { wxno });

                DataTable dtMain
                    = dbh.GetData(Main, new object[1] { wxno });

                DataTable dtHist
                    = dbh.GetData(Hist, new object[0]);


                //这里防止对象未初始化.
                if (dtUp != null && dtMain != null && dtHist != null)
                {
                    if (dtUp.Rows.Count > 0)
                    {
                        string date = this.dtList.Rows[0]["FinishDate"].ToString();
                        DateTime datetime = DateTime.Parse(date);
                        
                        dtUp.Rows[0]["IsFinish"]
                            = FilterSpecial(this.dtList.Rows[0]["IsFinish"].ToString());
                        dtUp.Rows[0]["FinishMan"]
                            = FilterSpecial(this.dtList.Rows[0]["FinishMan"].ToString());

                        dtUp.Rows[0]["FinishDate"]= datetime;
                        
                        dtUp.Rows[0]["FinishPoint"]
                            = FilterSpecial(this.dtList.Rows[0]["FinishPoint"].ToString());
                        dtUp.Rows[0]["FinishMoney"]
                            = FilterSpecial(this.dtList.Rows[0]["FinishMoney"].ToString());

                        dtUp.Rows[0]["ModifyUser"] = base.m_hzyMessage.User_Name;
                        dtUp.Rows[0]["ModifyTime"] = this.timeNow;
                    };

                    if (dtMain.Rows.Count > 0)
                    {
                        beforeStatus = dtMain.Rows[0]["Status"].ToString();
                        dtMain.Rows[0]["Status"] = "40";
                        dtMain.Rows[0]["ModifyTime"] = this.timeNow;
                        dtMain.Rows[0]["ModifyUser"] = base.m_hzyMessage.User_Name;
                    };

                    DataRow dr = dtHist.NewRow();

                    dr["Wxno"] = wxno;
                    dr["BeforeStatus"] = beforeStatus;
                    dr["AfterStatus"] = "40";
                    dr["Content"] = "维修单已经维修完成,结果为:"
                        + FilterSpecial(this.dtList.Rows[0]["IsFinish"].ToString());
                    dr["ModifyUser"] = base.m_hzyMessage.User_Name;

                    dtHist.Rows.Add(dr);

                    if (dtUp.Rows.Count > 0 && dtMain.Rows.Count > 0)
                    {
                        dtUp.TableName = "[dbo].[SPWX_Headquarters]";
                        dtMain.TableName = "[dbo].[SPWX_Main]";
                        dtHist.TableName = "[dbo].[SPWX_Hist]";

                        DataSet ds = new DataSet();

                        ds.Tables.Add(dtUp);
                        ds.Tables.Add(dtMain);
                        ds.Tables.Add(dtHist);

                        this.bRst = dbh.UpdateDB("ID", ds);

                        if (this.bRst)
                        {
                            drRow["result"] = true;
                            drRow["message"] = "提交成功";
                        }
                        else
                        {
                            drRow["result"] = false;
                            drRow["message"] = "提交失败";
                        };

                        this.dt_Return.Rows.Add(drRow);

                        this.ds_Return.Tables.Add(this.dt_Return);

                    };
                };
            }
            catch (Exception ex)
            {
                drRow["result"] = false;
                drRow["message"] = ex.Message;

                this.dt_Return.Rows.Add(drRow);

                this.ds_Return.Tables.Add(this.dt_Return);

            };

        }