Exemplo n.º 1
0
        public DataTable QuerySwitch(QueryType QT,
                                     ArrayList ParameterList
                                     )
        {
            DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
            DataTable Dt;

            try
            {
                switch (QT)
                {
                    case QueryType.ALL:
                        Dt = dbo.doQueryAll();
                        break;
                    case QueryType.CODE:
                        Dt = dbo.doQueryByCode(ParameterList);
                        break;
                    case QueryType.ID:
                        Dt = dbo.doQueryByID(ParameterList);
                        break;
                    case QueryType.Custom:
                        Dt = dbo.doQueryByFind(ParameterList);
                        break;
                    default:
                        Dt = new DataTable();
                        break;
                }

                return Dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
 public string GetSYS_CODE_DETLByCode(ArrayList ParameterList)
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.GetSYS_CODE_DETLByCode(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
 //取得最後一次結帳的年月
 public string GetLastCheckMonth()
 {
     try
     {
         string strResult = string.Empty;
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         DataTable dt = dbo.GetLastCheckMonth();
         strResult = dt.Rows[0]["check_month"].ToString();
         return strResult;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 public DataTable QueryVendorAgmByALL()
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.doQueryAll();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
        // 修改VDS_VDM_CONTRACT_MST基本檔資料(VDM022審核確認、合約解除使用)
        public void UpdateVDM_Contract(ArrayList ParameterList, ArrayList ArrList, DataSet ds, DbTransaction RootDBT)
        {
            //           1. VDS_VDM_CONTRACT_MST(合約主檔)
            //           2. VDS_VDM_CONTRACT_STORE(店群門市 -- 補貼運費 --> 要使用合約主檔的ID)
            //           3. VDS_VDM_CONTRACT_ITEM(單品 -- 多筆)
            //           4. VDS_VDM_CONTRACT_TARGET(獎勵金 -- 多筆)
            //           5. VDS_VDM_CONTRACT_STORE(店群門市 -- 獎勵金 --> 要使用獎勵金的ID)
            //           6. VDS_VDM_CONTRACT_ANUAL(年度獎勵金)
            //           7. VDS_VDM_CONTRACT_STORE(店群門市 -- 年度獎勵金 --> 要使用年度獎勵金的ID)
            //           8. VDS_VDM_TARGET_RANGE(目標級距)

            //ds.Tables["Table_0"];//VDS_VDM_CONTRACT_MST
            //ds.Tables["Table_1"];//VDS_VDM_CONTRACT_STORE
            //ds.Tables["Table_2"];//VDS_VDM_CONTRACT_ITEM
            //ds.Tables["Table_3"];//VDS_VDM_CONTRACT_TARGET
            //ds.Tables["Table_4"];//VDS_VDM_CONTRACT_STORE
            //ds.Tables["Table_5"];//VDS_VDM_TARGET_RANGE
            //ds.Tables["Table_6"];//VDS_VDM_CONTRACT_STORE
            //ds.Tables["Table_7"];//VDS_VDM_CONTRACT_ANNUAL

            bool IsRootTranscation = false;
            try
            {
                DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);

                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                int N_ID;

                dbo.UpdateVDS_VDM_CONTRACT_MST(ParameterList, DBT); //修改VDS_VDM_CONTRACT_MST合約主檔
                dbo.UpdateVDS_VDM_CONTRACT_ANNUAL(ArrList, DBT);    //修改VDS_VDM_CONTRACT_ANUAL年度獎勵金

                int P_ID = Int32.Parse(ds.Tables["Table_0"].Rows[0]["ID"].ToString());//使用合約主檔現有的ID
                string V_CNT_NO = ds.Tables["Table_0"].Rows[0]["CNT_NO"].ToString();//因為都沒有動到DataSet,所以DataSet的資料就是原始資料
                int N_EDIT_NO = Int32.Parse(ds.Tables["Table_0"].Rows[0]["EDIT_NO"].ToString());

                #region 店群門市、單品

                DataTable dt_i = ds.Tables["Table_1"].GetChanges(DataRowState.Added);
                DataTable dt_m = ds.Tables["Table_1"].GetChanges(DataRowState.Modified);
                DataTable dt_d = ds.Tables["Table_1"].GetChanges(DataRowState.Deleted);
                ArrayList arrayList = new ArrayList();

                if (dt_i != null)
                {
                    for (int i = 0; i <= dt_i.Rows.Count - 1; i++)//店群門市 -- 補貼運費 -> 新增
                    {
                        arrayList.Clear();
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值
                        arrayList.Add(dt_i.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                        arrayList.Add(dt_i.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                        arrayList.Add(dt_i.Rows[i]["STORE"].ToString());//V_STORE
                        arrayList.Add(ParameterList[28]);//D_CREATEDATE
                        arrayList.Add(ParameterList[29]);//V_CREATEUID
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                        arrayList.Add(P_ID);//N_PID
                        dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                    }
                    dt_i.Clear();
                }

                if (dt_m != null)
                {
                    for (int i = 0; i <= dt_m.Rows.Count - 1; i++)//店群門市 -- 補貼運費 -> 修改
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_m.Rows[i]["ID"].ToString());//V_CNT_NO
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_m.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_m.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值
                        arrayList.Add(dt_m.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                        arrayList.Add(dt_m.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                        arrayList.Add(dt_m.Rows[i]["STORE"].ToString());//V_STORE
                        arrayList.Add(ParameterList[28]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_UPDATEDATE
                        dbo.UpdateVDS_VDM_CONTRACT_STORE(arrayList, DBT);
                    }
                    dt_m.Clear();
                }

                if (dt_d != null)
                {
                    for (int i = 0; i <= dt_d.Rows.Count - 1; i++)//店群門市 -- 補貼運費 -> 刪除
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_d.Rows[i]["ID", DataRowVersion.Original].ToString());//N_ID
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_d.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_d.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[28]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_UPDATEDATE
                        dbo.DeleteVDS_VDM_CONTRACT_STORE(arrayList, DBT);
                    }
                    dt_d.Clear();
                }

                dt_i = ds.Tables["Table_2"].GetChanges(DataRowState.Added);
                dt_m = ds.Tables["Table_2"].GetChanges(DataRowState.Modified);
                dt_d = ds.Tables["Table_2"].GetChanges(DataRowState.Deleted);

                if (dt_i != null)
                {
                    for (int i = 0; i <= dt_i.Rows.Count - 1; i++)//單品 -- 補貼運費 -> 新增
                    {
                        arrayList.Clear();
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(dt_i.Rows[i]["ITEM"].ToString());//V_ITEM
                        arrayList.Add(dt_i.Rows[i]["PERIOD_B"].ToString());//V_PERIOD_B
                        arrayList.Add(dt_i.Rows[i]["PERIOD_E"].ToString());//V_PERIOD_E
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_CREATEDATE
                        arrayList.Add(ParameterList[28]);//V_CREATEUID
                        arrayList.Add(P_ID);//N_PID
                        dbo.doCreate_VDS_VDM_CONTRACT_ITEM(arrayList, DBT, out N_ID);
                    }
                    dt_i.Clear();
                }
                if (dt_m != null)
                {
                    for (int i = 0; i <= dt_m.Rows.Count - 1; i++)//單品 -- 補貼運費 -> 修改
                    {
                        arrayList.Clear();
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(dt_m.Rows[i]["ID"].ToString());//N_EDIT_NO 2009/11/30 改成ID(因原條件可能會有多筆的情況)
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_m.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_m.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(dt_m.Rows[i]["ITEM"].ToString());//V_ITEM
                        arrayList.Add(dt_m.Rows[i]["PERIOD_B"].ToString());//V_PERIOD_B
                        arrayList.Add(dt_m.Rows[i]["PERIOD_E"].ToString());//V_PERIOD_E
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        dbo.UpdateVDS_VDM_CONTRACT_ITEM(arrayList, DBT);
                    }
                    dt_m.Clear();
                }
                if (dt_d != null)
                {
                    for (int i = 0; i <= dt_d.Rows.Count - 1; i++)//單品 -- 補貼運費 -> 刪除
                    {
                        arrayList.Clear();
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(dt_d.Rows[i]["ID", DataRowVersion.Original].ToString());//N_EDIT_NO 2009/12/04 改成ID(因原條件可能會有多筆的情況)
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));//V_ITEM
                        arrayList.Add(dt_d.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());//V_PERIOD_B
                        arrayList.Add(dt_d.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());//V_PERIOD_E
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));//V_ITEM
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        dbo.DeleteVDS_VDM_CONTRACT_ITEM(arrayList, DBT);
                    }
                    dt_d.Clear();
                }
                #endregion

                #region 獎勵金、店群門市

                //把舊資料全部移除
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);//V_CNT_NO
                arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                arrayList.Add(ParameterList[29]);//V_UPDATEUID
                dbo.DeleteBath_VDS_VDM_CONTRACT_TARGET(arrayList, DBT); // VDS_VDM_CONTRACT_TARGET和VDS_VDM_CONTRACT_STORE            


                DataTable dt3 = ds.Tables["Table_3"];
                DataTable dt4 = ds.Tables["Table_4"];
                for (int i = 0; i <= dt3.Rows.Count - 1; i++) //獎勵金全部新增
                {
                    if (dt3.Rows[i].RowState != DataRowState.Deleted)
                    {
                        arrayList.Clear();
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(Convert.ToUInt32(dt3.Rows[i]["TARGET_TYPE"]));//N_TARGET_TYPE
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        if (dt3.Rows[i]["ACCEPT_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);
                        else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["ACCEPT_AMT"]));//N_ACCEPT_AMT
                        if (dt3.Rows[i]["RETURN_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);
                        else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["RETURN_AMT"]));//N_RETURN_AMT
                        if (dt3.Rows[i]["ACCEPT_RATE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);
                        else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["ACCEPT_RATE"]));//N_ACCEPT_RATE
                        if (dt3.Rows[i]["RETURN_RATE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);
                        else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["RETURN_RATE"]));//N_RETURN_RATE
                        if (dt3.Rows[i]["PAY_TYPE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);
                        else arrayList.Add(Convert.ToUInt32(dt3.Rows[i]["PAY_TYPE"]));//N_PAY_TYPE
                        if (dt3.Rows[i]["TARGET_RULE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);
                        else arrayList.Add(Convert.ToUInt32(dt3.Rows[i]["TARGET_RULE"]));//N_TARGET_RULE
                        arrayList.Add(dt3.Rows[i]["NOTES"].ToString());//V_NOTES
                        if (dt3.Rows[i]["MIN_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//N_MIN_AMT
                        else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["MIN_AMT"]));
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE                   
                        arrayList.Add(ParameterList[29]);//V_CREATEUID
                        arrayList.Add(ParameterList[28]);//D_CREATEDATE
                        dbo.doCreate_VDS_VDM_CONTRACT_TARGET(arrayList, DBT, out N_ID);

                        P_ID = N_ID;
                        if (dt4 != null)
                            foreach (DataRow dr in dt4.Rows)
                                if (dr.RowState != DataRowState.Deleted)
                                {
                                    if (dt3.Rows[i]["ID"].ToString() == dr["PID"].ToString())
                                    {
                                        arrayList.Clear();
                                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                                        arrayList.Add(dr["TARGET_NO"].ToString());//V_TARGET_NO 獎勵金對應編號
                                        arrayList.Add(dr["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                                        arrayList.Add(dr["STORE_GROUP"].ToString());//V_STORE_GROUP
                                        arrayList.Add(dr["STORE"].ToString());//V_STORE
                                        arrayList.Add(ParameterList[28]);//D_CREATEDATE
                                        arrayList.Add(ParameterList[29]);//V_CREATEUID
                                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                                        arrayList.Add(P_ID);//N_PID 新增獎勵金傳回的ID
                                        dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                                    }
                                }
                        DataRow[] drs = ds.Tables["Table_3"].Select("ID='" + dt3.Rows[i]["ID"].ToString() + "'");
                        drs[0]["ID"] = P_ID;
                    }
                }

                #endregion

                #region 年度獎勵金、目標級距、店群門市
                P_ID = Int32.Parse(ds.Tables["Table_7"].Rows[0]["ID"].ToString()); //年度獎勵金的ID

                dt_i = ds.Tables["Table_5"].GetChanges(DataRowState.Added);
                dt_m = ds.Tables["Table_5"].GetChanges(DataRowState.Modified);
                dt_d = ds.Tables["Table_5"].GetChanges(DataRowState.Deleted);

                if (dt_i != null)
                {
                    for (int i = 0; i <= dt_i.Rows.Count - 1; i++) //目標級距 -> 新增
                    {
                        arrayList.Clear();
                        arrayList.Add(P_ID);//N_PID
                        if (dt_i.Rows[i]["TARGET_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//N_TARGET_AMT
                        else arrayList.Add(Convert.ToDouble(dt_i.Rows[i]["TARGET_AMT"]));
                        if (dt_i.Rows[i]["YEAR_TARGET_PERCENT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//YEAR_TARGET_PERCENT
                        else arrayList.Add(Convert.ToDouble(dt_i.Rows[i]["YEAR_TARGET_PERCENT"]));
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE                   
                        arrayList.Add(ParameterList[29]);//V_CREATEUID
                        arrayList.Add(ParameterList[28]);//D_CREATEDATE
                        dbo.doCreate_VDS_VDM_TARGET_RANGE(arrayList, DBT, out N_ID);
                    }
                    dt_i.Clear();
                }

                if (dt_m != null)
                {
                    for (int i = 0; i <= dt_m.Rows.Count - 1; i++) //目標級距 -> 修改
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_m.Rows[i]["ID", DataRowVersion.Original].ToString());//N_PID
                        arrayList.Add(dt_m.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_m.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        if (dt_m.Rows[i]["TARGET_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//N_TARGET_AMT
                        else arrayList.Add(Convert.ToDouble(dt_m.Rows[i]["TARGET_AMT"]));
                        if (dt_m.Rows[i]["YEAR_TARGET_PERCENT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//YEAR_TARGET_PERCENT
                        else arrayList.Add(Convert.ToDouble(dt_m.Rows[i]["YEAR_TARGET_PERCENT"]));
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE                   
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        dbo.UpdateVDS_VDM_TARGET_RANGE(arrayList, DBT);
                    }
                    dt_m.Clear();
                }

                if (dt_d != null)
                {
                    for (int i = 0; i <= dt_d.Rows.Count - 1; i++) //目標級距 -> 刪除
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_d.Rows[i]["ID", DataRowVersion.Original].ToString());//N_PID
                        arrayList.Add(dt_d.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_d.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE                   
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        dbo.DeleteVDS_VDM_TARGET_RANGE(arrayList, DBT);
                    }
                    dt_d.Clear();
                }

                dt_i = ds.Tables["Table_6"].GetChanges(DataRowState.Added);
                dt_m = ds.Tables["Table_6"].GetChanges(DataRowState.Modified);
                dt_d = ds.Tables["Table_6"].GetChanges(DataRowState.Deleted);

                if (dt_i != null)
                {
                    for (int i = 0; i <= dt_i.Rows.Count - 1; i++)//店群門市 -- 年度獎勵金 -> 新增
                    {
                        arrayList.Clear();
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值
                        arrayList.Add(dt_i.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                        arrayList.Add(dt_i.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                        arrayList.Add(dt_i.Rows[i]["STORE"].ToString());//V_STORE
                        arrayList.Add(ParameterList[28]);//D_CREATEDATE
                        arrayList.Add(ParameterList[29]);//V_CREATEUID
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                        arrayList.Add(P_ID);//N_PID
                        dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                    }
                    dt_i.Clear();
                }

                if (dt_m != null)
                {
                    for (int i = 0; i <= dt_m.Rows.Count - 1; i++)//店群門市 -- 年度獎勵金 -> 修改
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_m.Rows[i]["ID"].ToString());//N_ID
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_m.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_m.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值
                        arrayList.Add(dt_m.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                        arrayList.Add(dt_m.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                        arrayList.Add(dt_m.Rows[i]["STORE"].ToString());//V_STORE
                        arrayList.Add(ParameterList[28]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_UPDATEDATE
                        dbo.UpdateVDS_VDM_CONTRACT_STORE(arrayList, DBT);
                    }
                    dt_m.Clear();
                }

                if (dt_d != null)
                {
                    for (int i = 0; i <= dt_d.Rows.Count - 1; i++)//店群門市 -- 年度獎勵金 -> 刪除
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_d.Rows[i]["ID", DataRowVersion.Original].ToString());//N_ID
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_d.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_d.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[28]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_UPDATEDATE
                        dbo.DeleteVDS_VDM_CONTRACT_STORE(arrayList, DBT);
                    }
                    dt_d.Clear();
                }
                #endregion

                //先把舊資料刪除再重新寫入

                #region 油價補貼 異動
                //刪除油價補貼(3&4)
                arrayList.Clear();
                arrayList.Add(ParameterList[1]);  //0.V_OLD_CNT_NO       varchar2,
                arrayList.Add(ParameterList[2]);  //1.N_OLD_EDIT_NO      number,
                arrayList.Add(2);                 //2.N_OLD_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[6]);  //3.V_OLD_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[5]);  //4.D_OLD_UPDATEDATE   date,                
                arrayList.Add(ParameterList[28]); //5.D_NEW_UPDATEDATE   date,
                arrayList.Add(ParameterList[29]); //6.V_NEW_UPDATEUID
                dbo.DeleteVDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT);
                arrayList.Clear();
                arrayList.Add(ParameterList[1]);  //V_OLD_CNT_NO       varchar2,
                arrayList.Add(ParameterList[2]);  //N_OLD_EDIT_NO      number,
                arrayList.Add(3);                 //N_OLD_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[6]);  //V_OLD_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[5]);  //D_OLD_UPDATEDATE   date,                
                arrayList.Add(ParameterList[28]); //D_NEW_UPDATEDATE   date,
                arrayList.Add(ParameterList[29]); //V_NEW_UPDATEUID
                dbo.DeleteVDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT);

                //新增油價補貼
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);          //V_CNT_NO       varchar2,
                arrayList.Add(N_EDIT_NO);         //N_EDIT_NO      number,           
                arrayList.Add(ParameterList[0]);  //V_VENDOR_CODE  varchar2,
                arrayList.Add(ParameterList[30]); //N_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[31]); //N_COUNT_TYPE   number,
                arrayList.Add(ParameterList[33]); //N_PAY_TYPE     number,
                arrayList.Add(ParameterList[32]); //N_SUBSIDY_RATE  number,
                arrayList.Add(ParameterList[29]); //V_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[28]); //D_UPDATEDATE   date,
                arrayList.Add(ParameterList[4]);  //V_CREATEUID    varchar2,
                arrayList.Add(ParameterList[3]);  //D_CREATEDATE   date,
                arrayList.Add(ParameterList[34]); //V_SUBSIDY_RULE varchar2
                dbo.doCreate_VDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT, out N_ID);

                dt_i = ds.Tables["Table_SUBSIDY2"].GetChanges(DataRowState.Added);
                dt_m = ds.Tables["Table_SUBSIDY2"].GetChanges(DataRowState.Modified);
                dt_d = ds.Tables["Table_SUBSIDY2"].GetChanges(DataRowState.Deleted);

                if (dt_d != null)
                {
                    for (int i = 0; i <= dt_d.Rows.Count - 1; i++)//店群門市 -- 補貼運費 -> 刪除
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_d.Rows[i]["ID", DataRowVersion.Original].ToString());//N_ID
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_d.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_d.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_d.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[28]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_UPDATEDATE
                        dbo.DeleteVDS_VDM_CONTRACT_STORE(arrayList, DBT);
                    }
                    dt_d.Clear();
                }

                if (dt_i != null)
                {
                    for (int i = 0; i <= dt_i.Rows.Count - 1; i++)//店群門市 -- 補貼運費 -> 新增
                    {
                        arrayList.Clear();
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值
                        arrayList.Add(dt_i.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                        arrayList.Add(dt_i.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                        arrayList.Add(dt_i.Rows[i]["STORE"].ToString());//V_STORE
                        arrayList.Add(ParameterList[28]);//D_CREATEDATE
                        arrayList.Add(ParameterList[29]);//V_CREATEUID
                        arrayList.Add(ParameterList[29]);//V_UPDATEUID
                        arrayList.Add(ParameterList[28]);//D_UPDATEDATE
                        arrayList.Add(P_ID);//N_PID
                        dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                    }
                    dt_i.Clear();
                }

                if (dt_m != null)
                {
                    for (int i = 0; i <= dt_m.Rows.Count - 1; i++)//店群門市 -- 補貼運費 -> 修改
                    {
                        arrayList.Clear();
                        arrayList.Add(dt_m.Rows[i]["ID"].ToString());//V_CNT_NO
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["CREATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(dt_m.Rows[i]["CREATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(dt_m.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Parse(dt_m.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString()));
                        arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                        arrayList.Add(V_CNT_NO);//V_CNT_NO
                        arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                        arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值
                        arrayList.Add(dt_m.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                        arrayList.Add(dt_m.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                        arrayList.Add(dt_m.Rows[i]["STORE"].ToString());//V_STORE
                        arrayList.Add(ParameterList[28]);//V_UPDATEUID
                        arrayList.Add(ParameterList[29]);//D_UPDATEDATE
                        dbo.UpdateVDS_VDM_CONTRACT_STORE(arrayList, DBT);
                    }
                    dt_m.Clear();
                }

                

                #endregion

                #region  離島配送費 異動
                //刪除離島配送費
                arrayList.Clear();
                arrayList.Add(ParameterList[1]);  //V_OLD_CNT_NO       varchar2,
                arrayList.Add(ParameterList[2]);  //N_OLD_EDIT_NO      number,
                arrayList.Add(1);                 //N_OLD_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[6]);  //V_OLD_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[5]);  //D_OLD_UPDATEDATE   date,                
                arrayList.Add(ParameterList[28]); //D_NEW_UPDATEDATE   date,
                arrayList.Add(ParameterList[29]); //V_NEW_UPDATEUID
                dbo.DeleteVDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT);
                //新增離島配送費
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);          //V_CNT_NO       varchar2,
                arrayList.Add(N_EDIT_NO);         //N_EDIT_NO      number,           
                arrayList.Add(ParameterList[0]);  //V_VENDOR_CODE  varchar2,
                arrayList.Add(1);                 //N_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[35]); //N_COUNT_TYPE   number,
                arrayList.Add(ParameterList[37]); //N_PAY_TYPE     number,
                arrayList.Add(ParameterList[36]); //N_SUBSIDY_RATE  number,
                arrayList.Add(ParameterList[29]); //V_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[28]); //D_UPDATEDATE   date,
                arrayList.Add(ParameterList[4]);  //V_CREATEUID    varchar2,
                arrayList.Add(ParameterList[3]);  //D_CREATEDATE   date,
                arrayList.Add(ParameterList[38]); //V_SUBSIDY_RULE varchar2
                dbo.doCreate_VDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT, out N_ID);
                #endregion

                #region 轉運費 異動
                //刪除轉運費
                arrayList.Clear();
                arrayList.Add(ParameterList[1]);  //V_OLD_CNT_NO       varchar2,
                arrayList.Add(ParameterList[2]);  //N_OLD_EDIT_NO      number,
                arrayList.Add(4);                 //N_OLD_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[6]);  //V_OLD_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[5]);  //D_OLD_UPDATEDATE   date,                
                arrayList.Add(ParameterList[28]); //D_NEW_UPDATEDATE   date,
                arrayList.Add(ParameterList[29]); //V_NEW_UPDATEUID
                dbo.DeleteVDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT);

                //新增轉運費
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);          //V_CNT_NO       varchar2,
                arrayList.Add(N_EDIT_NO);         //N_EDIT_NO      number,           
                arrayList.Add(ParameterList[0]);  //V_VENDOR_CODE  varchar2,
                arrayList.Add(4);                 //N_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[39]); //N_COUNT_TYPE   number,
                arrayList.Add(DBNull.Value);      //N_PAY_TYPE     number,
                arrayList.Add(DBNull.Value);      //N_SUBSIDY_RATE  number,
                arrayList.Add(ParameterList[29]); //V_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[28]); //D_UPDATEDATE   date,
                arrayList.Add(ParameterList[4]);  //V_CREATEUID    varchar2,
                arrayList.Add(ParameterList[3]);  //D_CREATEDATE   date,
                arrayList.Add(DBNull.Value);      //V_SUBSIDY_RULE varchar2
                dbo.doCreate_VDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT, out N_ID);
                #endregion

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }
                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                //if (IsRootTranscation)
                //{
                //獨立呼叫Transcation失敗
                DBT.Rollback();
                //}

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }
        }
Exemplo n.º 6
0
        //異動合約主檔履歷迄日
        public void UpdateResumeEDate(ArrayList ParameterList, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;

            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
                dbo.UpdateResumeEDate(ParameterList, DBT);

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 新增VDS_VDM_CONTRACT_MST基本檔資料
        /// </summary>
        /// <param name="ParameterList">合約主檔
        /// <param name="ArrList">年度獎勵金
        /// <param name="ds">店群門市、單品、獎勵金、目標級距
        /// <param name="isResume">是否為新增履歷
        public void CreateVendorAgm(ArrayList ParameterList, ArrayList ArrList, DataSet ds, DbTransaction RootDBT, bool isResume, out string V_CNT_NO)
        {
            //新增順序:  1. VDS_VDM_CONTRACT_MST(合約主檔)
            //           2. VDS_VDM_CONTRACT_STORE(店群門市 -- 補貼運費 --> 要使用合約主檔的ID)
            //           3. VDS_VDM_CONTRACT_ITEM(單品 -- 多筆)
            //           4. VDS_VDM_CONTRACT_TARGET(獎勵金 -- 多筆)
            //           5. VDS_VDM_CONTRACT_STORE(店群門市 -- 獎勵金 --> 要使用獎勵金的ID)
            //           6. VDS_VDM_CONTRACT_ANUAL(年度獎勵金)
            //           7. VDS_VDM_CONTRACT_STORE(店群門市 -- 年度獎勵金 --> 要使用年度獎勵金的ID)
            //           8. VDS_VDM_TARGET_RANGE(目標級距)

            bool IsRootTranscation = false;
            DataTable dt1 = ds.Tables["Table_1"];//VDS_VDM_CONTRACT_STORE
            DataTable dt2 = ds.Tables["Table_2"];//VDS_VDM_CONTRACT_ITEM
            DataTable dt3 = ds.Tables["Table_3"];//VDS_VDM_CONTRACT_TARGET
            DataTable dt4 = ds.Tables["Table_4"];//VDS_VDM_CONTRACT_STORE
            DataTable dt5 = ds.Tables["Table_5"];//VDS_VDM_TARGET_RANGE
            DataTable dt6 = ds.Tables["Table_6"];//VDS_VDM_CONTRACT_STORE
            DataTable dtSUBSIDY2 = ds.Tables["Table_SUBSIDY2"];//VDS_VDM_CONTRACT_STORE
            try
            {
                DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);

                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                int N_ID, N_EDIT_NO;
                //string V_CNT_NO;

                //先新增VDS_VDM_CONTRACT_MST合約主檔取得合約編號,以便傳給店群、單品
                if (isResume)
                {
                    dbo.doCreate_VDS_VDM_CONTRACT_MST_Resume(ParameterList, DBT, out N_ID);
                    V_CNT_NO = ParameterList[24].ToString();
                    N_EDIT_NO = Convert.ToInt16(ParameterList[1]);
                }
                else
                {
                    dbo.doCreate_VDS_VDM_CONTRACT_MST(ParameterList, DBT, out N_ID, out V_CNT_NO);
                    N_EDIT_NO = 1;
                }

                int P_ID = N_ID; //新增合約主檔傳回的ID
                ArrayList arrayList = new ArrayList();

                for (int i = 0; i <= dt1.Rows.Count - 1; i++)//店群門市 -- 補貼運費
                {
                    arrayList.Clear();
                    arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                    arrayList.Add(V_CNT_NO);//V_CNT_NO 新增合約主檔傳回的合約編號
                    arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                    arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值,其他的給0
                    arrayList.Add(dt1.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                    arrayList.Add(dt1.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                    arrayList.Add(dt1.Rows[i]["STORE"].ToString());//V_STORE
                    arrayList.Add(ParameterList[21]);//D_CREATEDATE
                    arrayList.Add(ParameterList[20]);//V_CREATEUID
                    arrayList.Add(ParameterList[22]);//V_UPDATEUID
                    arrayList.Add(ParameterList[23]);//D_UPDATEDATE
                    arrayList.Add(P_ID);//N_PID 新增合約主檔傳回的ID
                    dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                }

                for (int i = 0; i <= dt2.Rows.Count - 1; i++)//單品 -- 補貼運費
                {
                    arrayList.Clear();
                    arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                    arrayList.Add(V_CNT_NO);//V_CNT_NO
                    arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                    arrayList.Add(dt2.Rows[i]["ITEM"].ToString());//V_ITEM
                    arrayList.Add(dt2.Rows[i]["PERIOD_B"].ToString());//V_PERIOD_B
                    arrayList.Add(dt2.Rows[i]["PERIOD_E"].ToString());//V_PERIOD_E
                    arrayList.Add(ParameterList[23]);//D_UPDATEDATE
                    arrayList.Add(ParameterList[22]);//V_UPDATEUID
                    arrayList.Add(ParameterList[20]);//V_CREATEUID
                    arrayList.Add(ParameterList[21]);//D_CREATEDATE
                    arrayList.Add(P_ID);//N_PID
                    dbo.doCreate_VDS_VDM_CONTRACT_ITEM(arrayList, DBT, out N_ID);
                }

                for (int i = 0; i <= dt3.Rows.Count - 1; i++) //獎勵金
                {
                    arrayList.Clear();
                    arrayList.Add(V_CNT_NO);//V_CNT_NO 新增合約主檔傳回的合約編號
                    arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                    arrayList.Add(Convert.ToUInt32(dt3.Rows[i]["TARGET_TYPE"]));//N_TARGET_TYPE
                    arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                    if (dt3.Rows[i]["ACCEPT_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//ACCEPT_AMT
                    else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["ACCEPT_AMT"]));
                    if (dt3.Rows[i]["RETURN_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//RETURN_AMT
                    else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["RETURN_AMT"]));
                    if (dt3.Rows[i]["ACCEPT_RATE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//ACCEPT_RATE
                    else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["ACCEPT_RATE"]));
                    if (dt3.Rows[i]["RETURN_RATE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//RETURN_RATE
                    else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["RETURN_RATE"]));
                    if (dt3.Rows[i]["PAY_TYPE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//PAY_TYPE
                    else arrayList.Add(Convert.ToUInt32(dt3.Rows[i]["PAY_TYPE"]));
                    if (dt3.Rows[i]["TARGET_RULE"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//TARGET_RULE
                    else arrayList.Add(Convert.ToUInt32(dt3.Rows[i]["TARGET_RULE"]));
                    arrayList.Add(dt3.Rows[i]["NOTES"].ToString());//V_NOTES
                    if (dt3.Rows[i]["MIN_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//N_MIN_AMT
                    else arrayList.Add(Convert.ToDouble(dt3.Rows[i]["MIN_AMT"]));
                    arrayList.Add(ParameterList[22]);//V_UPDATEUID
                    arrayList.Add(ParameterList[23]);//D_UPDATEDATE                   
                    arrayList.Add(ParameterList[20]);//V_CREATEUID
                    arrayList.Add(ParameterList[21]);//D_CREATEDATE
                    dbo.doCreate_VDS_VDM_CONTRACT_TARGET(arrayList, DBT, out N_ID);

                    P_ID = N_ID;
                    foreach (DataRow dr in dt4.Rows)
                        if (dt3.Rows[i]["ID"].ToString() == dr["PID"].ToString())
                        {
                            arrayList.Clear();
                            arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                            arrayList.Add(V_CNT_NO);//V_CNT_NO 新增合約主檔傳回的合約編號
                            arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                            arrayList.Add(dr["TARGET_NO"].ToString());//V_TARGET_NO 獎勵金對應編號
                            arrayList.Add(dr["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                            arrayList.Add(dr["STORE_GROUP"].ToString());//V_STORE_GROUP
                            arrayList.Add(dr["STORE"].ToString());//V_STORE
                            arrayList.Add(ParameterList[21]);//D_CREATEDATE
                            arrayList.Add(ParameterList[20]);//V_CREATEUID
                            arrayList.Add(ParameterList[22]);//V_UPDATEUID
                            arrayList.Add(ParameterList[23]);//D_UPDATEDATE
                            arrayList.Add(P_ID);//N_PID 新增合約主檔傳回的ID
                            dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                        }
                }

                //先新增VDS_VDM_CONTRACT_ANUAL年度獎勵金取得合約編號及ID,以便傳給店群、目標級距
                dbo.doCreate_VDS_VDM_CONTRACT_ANNUAL(V_CNT_NO, ArrList, DBT, out N_ID);
                P_ID = N_ID; //新增年度獎勵金傳回的ID

                for (int i = 0; i <= dt5.Rows.Count - 1; i++) //目標級距
                {
                    arrayList.Clear();
                    arrayList.Add(P_ID);//N_PID
                    if (dt5.Rows[i]["TARGET_AMT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//ACCEPT_AMT
                    else arrayList.Add(Convert.ToDouble(dt5.Rows[i]["TARGET_AMT"]));
                    if (dt5.Rows[i]["YEAR_TARGET_PERCENT"].ToString().Length == 0) arrayList.Add(System.DBNull.Value);//ACCEPT_AMT
                    else arrayList.Add(Convert.ToDouble(dt5.Rows[i]["YEAR_TARGET_PERCENT"]));
                    arrayList.Add(ParameterList[22]);//V_UPDATEUID
                    arrayList.Add(ParameterList[23]);//D_UPDATEDATE                   
                    arrayList.Add(ParameterList[20]);//V_CREATEUID
                    arrayList.Add(ParameterList[21]);//D_CREATEDATE
                    dbo.doCreate_VDS_VDM_TARGET_RANGE(arrayList, DBT, out N_ID);
                }

                for (int i = 0; i <= dt6.Rows.Count - 1; i++)//店群門市 -- 年度獎勵金
                {
                    arrayList.Clear();
                    arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                    arrayList.Add(V_CNT_NO);//V_CNT_NO 新增合約主檔傳回的合約編號
                    arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                    arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值,其他給0
                    arrayList.Add(dt6.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                    arrayList.Add(dt6.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                    arrayList.Add(dt6.Rows[i]["STORE"].ToString());//V_STORE
                    arrayList.Add(ParameterList[21]);//D_CREATEDATE
                    arrayList.Add(ParameterList[20]);//V_CREATEUID
                    arrayList.Add(ParameterList[22]);//V_UPDATEUID
                    arrayList.Add(ParameterList[23]);//D_UPDATEDATE
                    arrayList.Add(P_ID);//N_PID 新增年度獎勵金傳回的ID
                    dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                }

                //油價補貼
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);          //V_CNT_NO       varchar2,
                arrayList.Add(N_EDIT_NO);         //N_EDIT_NO      number,           
                arrayList.Add(ParameterList[0]);  //V_VENDOR_CODE  varchar2,
                arrayList.Add(ParameterList[25]); //N_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[26]); //N_COUNT_TYPE   number,
                arrayList.Add(ParameterList[28]); //N_PAY_TYPE     number,
                arrayList.Add(ParameterList[27]); //N_SUBSIDY_RATE  number,
                arrayList.Add(ParameterList[22]); //V_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[23]); //D_UPDATEDATE   date,
                arrayList.Add(ParameterList[20]); //V_CREATEUID    varchar2,
                arrayList.Add(ParameterList[21]); //D_CREATEDATE   date,
                arrayList.Add(ParameterList[29]); //V_SUBSIDY_RULE varchar2
                dbo.doCreate_VDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT, out N_ID);

                //離島配送費
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);          //V_CNT_NO       varchar2,
                arrayList.Add(N_EDIT_NO);         //N_EDIT_NO      number,           
                arrayList.Add(ParameterList[0]);  //V_VENDOR_CODE  varchar2,
                arrayList.Add(1);                 //N_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[30]); //N_COUNT_TYPE   number,
                arrayList.Add(ParameterList[32]); //N_PAY_TYPE     number,
                arrayList.Add(ParameterList[31]); //N_SUBSIDY_RATE  number,
                arrayList.Add(ParameterList[22]); //V_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[23]); //D_UPDATEDATE   date,
                arrayList.Add(ParameterList[20]); //V_CREATEUID    varchar2,
                arrayList.Add(ParameterList[21]); //D_CREATEDATE   date,
                arrayList.Add(ParameterList[33]); //V_SUBSIDY_RULE varchar2
                dbo.doCreate_VDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT, out N_ID);

                //離島配送費
                arrayList.Clear();
                arrayList.Add(V_CNT_NO);          //V_CNT_NO       varchar2,
                arrayList.Add(N_EDIT_NO);         //N_EDIT_NO      number,           
                arrayList.Add(ParameterList[0]);  //V_VENDOR_CODE  varchar2,
                arrayList.Add(4);                 //N_SUBSIDY_TYPE number,
                arrayList.Add(ParameterList[34]); //N_COUNT_TYPE   number,
                arrayList.Add(DBNull.Value); //N_PAY_TYPE     number,
                arrayList.Add(DBNull.Value); //N_SUBSIDY_RATE  number,
                arrayList.Add(ParameterList[22]); //V_UPDATEUID    varchar2,
                arrayList.Add(ParameterList[23]); //D_UPDATEDATE   date,
                arrayList.Add(ParameterList[20]); //V_CREATEUID    varchar2,
                arrayList.Add(ParameterList[21]); //D_CREATEDATE   date,
                arrayList.Add(DBNull.Value); //V_SUBSIDY_RULE varchar2
                dbo.doCreate_VDS_VDM_CONTRACT_SUBSIDY(arrayList, DBT, out N_ID);

                for (int i = 0; i <= dtSUBSIDY2.Rows.Count - 1; i++)//店群門市 -- 油價補貼
                {
                    arrayList.Clear();
                    arrayList.Add(ParameterList[0]);//V_VENDOR_CODE
                    arrayList.Add(V_CNT_NO);//V_CNT_NO 新增合約主檔傳回的合約編號
                    arrayList.Add(N_EDIT_NO);//N_EDIT_NO
                    arrayList.Add(0);//V_TARGET_NO 獎勵金對應編號,只有COUNT_TYPE=2(獎勵金) 才會有值,其他給0
                    arrayList.Add(dtSUBSIDY2.Rows[i]["COUNT_TYPE"].ToString());//V_COUNT_TYPE
                    arrayList.Add(dtSUBSIDY2.Rows[i]["STORE_GROUP"].ToString());//V_STORE_GROUP
                    arrayList.Add(DBNull.Value);//V_STORE
                    arrayList.Add(ParameterList[21]);//D_CREATEDATE
                    arrayList.Add(ParameterList[20]);//V_CREATEUID
                    arrayList.Add(ParameterList[22]);//V_UPDATEUID
                    arrayList.Add(ParameterList[23]);//D_UPDATEDATE
                    arrayList.Add(P_ID);//N_PID 新增年度獎勵金傳回的ID
                    dbo.doCreate_VDS_VDM_CONTRACT_STORE(arrayList, DBT, out N_ID);
                }

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }
                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                //if (IsRootTranscation)
                //{
                //獨立呼叫Transcation失敗
                DBT.Rollback();
                //}

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }
        }
Exemplo n.º 8
0
 public int CheckContDup(ArrayList ParameterList)
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.CheckContDup(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
 public string QueryMaxEditNo(ArrayList ParameterList)
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.QueryMaxEditNo(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// 判斷該合約是否已做過供應商月結
 /// </summary>
 /// <param name="ParameterList"></param>
 /// <returns>大於0表已做過月結</returns>
 public int QueryisCheckOut(ArrayList ParameterList)
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.QueryisCheckOut(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 找出最大的結帳年月
 /// </summary>
 /// <returns></returns>
 public string QueryMaxYM()
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.QueryMaxYM();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 12
0
 public DataTable QuerySys_Code_Detl()
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.QuerySys_Code_Detl();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 13
0
 public DataTable QueryForSLP(ArrayList ParameterList)
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.QueryForSLP(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 14
0
 //for VDM021
 //無論是否有關鍵字搜尋,皆可呼叫此Fun
 public DataTable QueryAgmByALL(ArrayList ParameterList)
 {
     try
     {
         DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
         return dbo.doQuery_VDM021(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 15
0
        //停止往來
        public void StopCloseMonth(ArrayList ParameterList, DbTransaction RootDBT, out string V_MSG, out string V_STATUS_CREATEUID, out DateTime D_STATUS_CREATEDATE)
        {
            bool IsRootTranscation = false;

            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                DBO.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB);
                dbo.StopCloseMonthSKU(ParameterList, DBT, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);//停止往來.商品交易
                if (V_MSG == "")
                {
                    dbo.StopCloseMonthContract(ParameterList, DBT, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);//停止往來.合約交易
                    if (V_MSG == "")
                    {
                        dbo.UpdateStopCalculate(ParameterList, DBT);//停止計算完後異動合約主檔的停止往來日
                    }
                }

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }
        }