Пример #1
0
        /// <summary>
        /// VAM23異常資料報表
        /// </summary>
        /// <param name="ParameterList">變數清單</param>
        /// <returns>回傳查詢結果</returns>
        public DataTable VAM23_1(ArrayList ParameterList)
        {
            #region 宣告變數

            BCO.CAMCommon CAMCommonBCO = new BCO.CAMCommon();
            ArrayList arl_ReportService = new ArrayList();
            DataTable dt_Return = new DataTable();

            #endregion

            #region 傳入參數

            arl_ReportService.Clear();

            arl_ReportService.Add(CAMCommonBCO.GetValueSetParameter(ParameterList[0].ToString(), "string", false));
            arl_ReportService.Add(CAMCommonBCO.GetValueSetParameter(ParameterList[1].ToString(), "string", false));
            arl_ReportService.Add(CAMCommonBCO.GetValueSetParameter(ParameterList[2].ToString(), "string", false));
            arl_ReportService.Add(CAMCommonBCO.GetValueSetParameter(ParameterList[3].ToString(), "int", false));
            arl_ReportService.Add(CAMCommonBCO.GetValueSetParameter(ParameterList[4].ToString(), "string", false));

            #endregion

            #region 連結資料庫

            VAM23_BCO bco = new VAM23_BCO(ConntionDB);
            dt_Return = bco.QueryError(arl_ReportService);

            #endregion

            #region 檢查回傳資料

            if (dt_Return.Rows.Count == 0)
            { throw new Exception("查無資料"); }
            else
            { return dt_Return; }

            #endregion
        }
Пример #2
0
    private void QueryData()
    {
        #region
        DateTime dateA;
        if (SLP_YearMonth2.Text.Trim().Length != 6)
        {
            ErrorMsgLabel.Text = "年月格式有誤,請重新輸入";
        }
        else if (DateTime.TryParse(SLP_YearMonth2.Text.Substring(0, 4) + "/" + SLP_YearMonth2.Text.Substring(4, 2) + "/01", out dateA) == false)
        {
            ErrorMsgLabel.Text = "年月格式有誤,請重新輸入";
        }
        else
        {
            CAMCommon CAMCommonBCO = new CAMCommon();
            DataTable dt_Return = new DataTable();
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(rblCloseType.SelectedValue, "string", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_YearMonth2.Text, "string", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_VENDOR.Text, "string", false));
            Int32 iTopRowNum;
            Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum);
            ParameterList.Add(iTopRowNum);
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(Session["UID"].ToString(), "string", false));

            BCO.VAM23_BCO BCO = new BCO.VAM23_BCO(ConntionDB);
            dt_Return = BCO.QueryError(ParameterList);

            if (dt_Return.Rows.Count > 0)
            {
                string SessionIDName = string.Format("{0}_{1}", PageProgramCode, PageTimeStamp.Value);
                Session["SessionID"] = SessionIDName;
                Session[SessionIDName] = dt_Return;
                this.gv_ErrorData.DataSource = dt_Return.DefaultView;

                this.gv_ErrorData.PageSize = (TextBoxPagesize.Text == "") ? 50 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 50 : int.Parse(TextBoxPagesize.Text);
                this.gv_ErrorData.PageIndex = 0;
                this.gv_ErrorData.DataBind();
            }
            else
            {
                this.gv_ErrorData.DataBind();
                ErrorMsgLabel.Text = "查無資料";
            }
        }

        up_ErrorMsg.Update();
        up_GridView.Update();
        #endregion
    }
Пример #3
0
    /// <summary>
    /// 匯入檔案
    /// </summary>
    /// <param name="s_FilePathName"></param>
    /// <returns></returns>
    private bool ImportDocument(string s_FilePathName)
    {
        #region
        bool bResult = false;
        try
        {
            string strBatch_No = "",
                   strVendor = "",
                   strDeliv_Date = "",
                   strSales_Date = "", 
                   strStakind = "", 
                   strChan_Source_No = "",
                   strItem_No = "",
                   strItem_Map = "",
                   strBarcode = "", 
                   strSales_Qty = "", 
                   strTax_Type = "",
                   strLoginId = Session["UID"].ToString();

            ArrayList ParameterList = new ArrayList();
            BCO.VAM23_BCO bco = new BCO.VAM23_BCO(ConntionDB);
            int ROW_ID = 0;
            DateTime dtTemp;
            Int64 iTemp;
            //一行一行的取讀取文字檔內的資料  System.Text.Encoding.Default才不會讀到亂碼
            StreamReader stmRdr = new StreamReader(s_FilePathName, System.Text.Encoding.Default);
            string line = "";
            string Err = "";

            DataTable dt = new DataTable();
            dt.Columns.Add("ROW_ID", typeof(int));
            dt.Columns.Add("LINE_DATA", typeof(string));
            dt.Columns.Add("ERRMEMO", typeof(string));

            DataTable dt1 = new DataTable();
            dt1.Columns.Add("ROW_ID", typeof(int));
            dt1.Columns.Add("BATCH_NO", typeof(string));
            dt1.Columns.Add("SALES_MONTH", typeof(string));
            dt1.Columns.Add("VENDOR", typeof(string));
            dt1.Columns.Add("DELIV_DATE", typeof(DateTime));
            dt1.Columns.Add("SALES_DATE", typeof(DateTime));
            dt1.Columns.Add("STAKIND", typeof(string));
            dt1.Columns.Add("CHAN_SOURCE_NO", typeof(string));
            dt1.Columns.Add("ITEM_NO", typeof(string));
            dt1.Columns.Add("ITEM_MAP", typeof(string));
            dt1.Columns.Add("BARCODE", typeof(string));
            dt1.Columns.Add("SALES_QTY", typeof(int));
            dt1.Columns.Add("TAX_TYPE", typeof(int));
            dt1.Columns.Add("USERID", typeof(string));

            while (line != null)
            {
                ROW_ID += 1;
                Err = "";

                strBatch_No = "";
                strVendor = "";
                strDeliv_Date = "";
                strSales_Date = ""; 
                strStakind = ""; 
                strChan_Source_No = "";
                strItem_No = "";
                strItem_Map = "";
                strBarcode = ""; 
                strSales_Qty = "";
                strTax_Type = "";
                strLoginId = Session["UID"].ToString();

                ParameterList.Clear();

                System.Diagnostics.Debug.WriteLine(line);

                line = stmRdr.ReadLine();

                if (line != null)
                {
                    if (line.Length > 0)
                    {
                        if (line.Length == 109)
                        {
                            strVendor = line.Substring(0, 10);
                            strDeliv_Date = line.Substring(10, 8);
                            strSales_Date = line.Substring(18, 8);
                            strStakind = line.Substring(26, 2);
                            strChan_Source_No = line.Substring(28, 20);
                            strItem_No = line.Substring(48, 14);
                            strItem_Map = line.Substring(62, 20);
                            strBarcode = line.Substring(82, 20);
                            strSales_Qty = line.Substring(102, 6);
                            strTax_Type = line.Substring(108 ,1);

                            if (strSales_Date.ToString().Trim() == string.Empty ||
                               strBarcode.ToString().Trim() == string.Empty ||
                               strSales_Qty.ToString().Trim() == string.Empty||
                               strChan_Source_No.ToString().Trim() == string.Empty)
                            {
                                Err = "入帳日/條碼/銷售數量/出貨單編號不可為空白!";
                                break;
                            }

                            DataRow[] row1 = (DataRow[])dt1.Select("BARCODE='" + strBarcode.Trim() + "' AND CHAN_SOURCE_NO='" + strChan_Source_No.Trim() + "'");
                            if (row1.Length > 0)
                            {
                                foreach (DataRow drTemp in row1)
                                {
                                    if (DateTime.Parse(drTemp["SALES_DATE"].ToString()).ToString("yyyy/MM/dd") == strSales_Date.Substring(0, 4) + "/" + strSales_Date.Substring(4, 2) + "/" + strSales_Date.Substring(6, 2))
                                    {
                                        Err = Err + "入帳日:" + strSales_Date + "出貨單編號:" + strChan_Source_No + ",條碼:" + strBarcode + ",資料重複;";

                                        break;
                                    }
                                }
                            }

                            if (strVendor.Trim() != "")
                            {
                                if (!IsNumAndEnCh(strVendor))
                                {
                                    Err = Err + "1~10格式錯誤;";
                                }
                            }

                            if (strDeliv_Date.Trim() != "")
                            {
                                if (!DateTime.TryParse(strDeliv_Date.Substring(0, 4) + "/" + strDeliv_Date.Substring(4, 2) + "/" + strDeliv_Date.Substring(6, 2), out dtTemp))
                                {
                                    Err = Err + "11~18格式錯誤;";
                                }
                            }

                            if (strSales_Date.Trim() == "" || !DateTime.TryParse(strSales_Date.Substring(0, 4) + "/" + strSales_Date.Substring(4, 2) + "/" + strSales_Date.Substring(6, 2), out dtTemp))
                            {
                                Err = Err + "19~26格式錯誤;";
                            }

                            if (strStakind.Trim() != "")
                            {
                                if (!Int64.TryParse(strStakind, out iTemp))
                                {
                                    Err = Err + "27~28格式錯誤;";
                                }
                            }

                            if (strChan_Source_No.Trim() != "")
                            {
                                if (!IsNumAndEnCh(strChan_Source_No.Trim()))
                                {
                                    Err = Err + "29~48格式錯誤;";
                                }
                            }

                            if (strItem_No.Trim() != "")
                            {
                                if (!IsNumAndEnCh(strItem_No.Trim()))
                                {
                                    Err = Err + "49~62格式錯誤;";
                                }
                            }

                            if (strItem_Map.Trim() != "")
                            {
                                if (!IsNumAndEnCh(strItem_Map.Trim()))
                                {
                                    Err = Err + "63~82格式錯誤;";
                                }
                            }
   
                            if (strBarcode.Trim() == "" || !Int64.TryParse(strBarcode.Trim(), out iTemp))
                            {
                                Err = Err + "83~102格式錯誤;";
                            }

                            if (strSales_Qty.Trim() == "" || !Int64.TryParse(strSales_Qty.Trim(), out iTemp))
                            {
                                Err = Err + "103~108格式錯誤;";
                            }

                            if (strTax_Type.Trim() != "")
                            {
                                if (!Int64.TryParse(strTax_Type, out iTemp))
                                {
                                    Err = Err + "109~109格式錯誤;";
                                }
                            }
                        }
                        else
                        {
                            Err = "資料長度不正確";
                        }

                        DataRow dr;
                        if (Err != "")
                        {
                            dr = dt.NewRow();

                            dr[0] = ROW_ID;
                            dr[1] = line;
                            dr[2] = Err;

                            dt.Rows.Add(dr);
                        }
                        else
                        {
                            dr = dt1.NewRow();

                            dr[0] = ROW_ID;

                            strBatch_No = s_FilePathName.Replace(".delivery", "");
                            strBatch_No = strBatch_No.Substring(strBatch_No.Length-10, 10);

                            dr[1] = strBatch_No;
                            dr[2] = SLP_YearMonth1.Text;
                            dr[3] = strVendor.Trim();

                            if (strDeliv_Date.Trim() != "")
                            {
                                dr[4] = DateTime.Parse(strDeliv_Date.Substring(0, 4) + "/" + strDeliv_Date.Substring(4, 2) + "/" + strDeliv_Date.Substring(6, 2));
                            }
                            else
                            {
                                dr[4] = null;
                            }

                            dr[5] = DateTime.Parse(strSales_Date.Substring(0, 4) + "/" + strSales_Date.Substring(4, 2) + "/" + strSales_Date.Substring(6, 2));
                            dr[6] = strStakind.Trim();
                            dr[7] = strChan_Source_No.Trim();
                            dr[8] = strItem_No.Trim();
                            dr[9] = strItem_Map.Trim();
                            dr[10] = strBarcode.Trim();
                            dr[11] = int.Parse(strSales_Qty.Trim());

                            if (strTax_Type.Trim() == "")
                            {
                                dr[12] = null;
                            }
                            else
                            {
                                dr[12] = int.Parse(strTax_Type.Trim());
                            }

                            dr[13] = strLoginId;

                            dt1.Rows.Add(dr);
                        }
                    }
                }
            }

            string SessionIDName = string.Format("{0}_{1}_7net", PageProgramCode, PageTimeStamp.Value);
            Session[SessionIDName] = null;
            if (dt.Rows.Count > 0)
            {
                Session[SessionIDName] = dt;
                bResult = false;
            }
            else if (dt1.Rows.Count > 0)
            {
                Session[SessionIDName] = dt1;
                bResult = true;
            }

            stmRdr.Close();
            stmRdr.Dispose();
        }
        catch (Exception ex)
        {
            throw ex;
        }

        return bResult;
        #endregion
    }
Пример #4
0
    public void TransFor7netOld()
    {
        #region

        string[] strReturn = new string[2];
        strReturn[0] = "";
        strReturn[1] = "";

        try
        {
            BCO.VAM23_BCO bco = new BCO.VAM23_BCO(ConntionDB);
            ArrayList ParameterList = new ArrayList();

            ParameterList.Add("Y");
            ParameterList.Add("VAM23");
            ParameterList.Add(SLP_YearMonth1.Text);
            ParameterList.Add(Session["UID"].ToString());

            strReturn = bco.CreateVdsVamSalesItemFor7net(ParameterList, null);
        }
        catch (Exception ex)
        {
            strReturn[0] = "2";
            strReturn[1] = ex.Message;
        }
        #endregion

        if (strReturn[0] == "2")
        {
            ErrorMsgLabel.Text = strReturn[1];
        }
    }
Пример #5
0
    public void SetTran()
    {
        #region

        string[] strReturn = new string[2];
        strReturn[0] = "";
        strReturn[1] = "";

        try
        {
            DateTime dateA;
            if (SLP_YearMonth1.Text.Length != 6)
            {
                strReturn[0] = "2";
                strReturn[1] = "年月格式有誤,請重新輸入";
            }
            else if (DateTime.TryParse(SLP_YearMonth1.Text.Substring(0, 4) + "/" + SLP_YearMonth1.Text.Substring(4, 2) + "/01", out dateA) == false)
            {
                strReturn[0] = "2";
                strReturn[1] = "年月格式有誤,請重新輸入";
            }
            else
            {
                #region
                BCO.VAM23_BCO bco = new BCO.VAM23_BCO(ConntionDB);
                ArrayList ParameterList = new ArrayList();

                if (rblCntType.SelectedValue == "1")
                {
                    ParameterList.Clear();

                    ParameterList.Add(SLP_YearMonth1.Text);
                    ParameterList.Add(rblCntType.SelectedValue);
                    ParameterList.Add("VAM23");
                    ParameterList.Add(Session["UID"].ToString());

                    strReturn = bco.CreateVdsVamSalesItem(ParameterList, null);
                }
                else if (rblCntType.SelectedValue == "2")
                {
                    bool bResult = false;
                     
                    DirectoryInfo di = new DirectoryInfo(File_Path_IN);
                    if (di.GetFiles("*.delivery").Length == 1 && di.GetFiles("*.ok").Length == 1)
                    {
                         FileInfo[] rgFiles = di.GetFiles("*.delivery");
                         foreach(FileInfo fi in rgFiles)
                         {
                             bResult = true;
                             if (fi.Name.Length != 28)
                             {
                                 ErrorMsgLabel.Text = "delivery檔名格式錯誤";
                                 bResult = false;
                             }
                             else
                             {
                                 if (fi.Name.Substring(0, 9) != "7nET_POS_")
                                 {
                                     ErrorMsgLabel.Text = "delivery檔名格式錯誤";
                                     bResult = false;
                                 }

                                 DateTime dtTemp;
                                 if (!DateTime.TryParse(fi.Name.Substring(9, 4) + "/" + fi.Name.Substring(13, 2) + "/" + fi.Name.Substring(15, 2), out dtTemp))
                                 {
                                     ErrorMsgLabel.Text = "delivery檔名格式錯誤";
                                     bResult = false;
                                 }

                                 int iTemp;
                                 if (!int.TryParse(fi.Name.Substring(17, 2), out iTemp))
                                 {
                                     ErrorMsgLabel.Text = "delivery檔名格式錯誤";
                                     bResult = false;
                                 }

                                 if (bResult)
                                 {
                                     File_Path_Name = string.Format("{0}\\{1}", File_Path_IN, fi.Name + ".ok");
                                     bResult = CheckDocumentIsExisted();

                                     if (!bResult)
                                     {
                                         ErrorMsgLabel.Text = "找不到ok檔";
                                         bResult = false;
                                     }
                                     else if (fi.Length == 0)
                                     {
                                         ErrorMsgLabel.Text = "本月無 7NET 結算資料";
                                         
                                         ParameterList.Clear();
                                         ParameterList.Add("VAM23");
                                         ParameterList.Add(SLP_YearMonth1.Text);
                                         ParameterList.Add(Session["UID"].ToString());

                                         bco.Update_VDS_VAM_MON_CLS(ParameterList, null);

                                         MoveFileToBackup();

                                         bResult = false;
                                     }
                                     else
                                     {
                                         File_Path_Name = string.Format("{0}\\{1}", File_Path_IN, fi.Name);
                                     }
                                 }
                             }

                             if (!bResult)
                             {
                                 return;
                             }
                         }
                    }
                    else
                    {
                        ErrorMsgLabel.Text = "必須有一個delivery檔和一個ok檔,不可多於或少於一個";

                        bResult = false;
                    }

                    if (!bResult)
                    {
                        ParameterList.Clear();

                        ParameterList.Add(SLP_YearMonth1.Text);
                        ParameterList.Add(Session["UID"].ToString());

                        strReturn = bco.Query_SALES_ITEM_7NET(ParameterList, null);

                        if (strReturn[0] == "3")
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "if (confirm('" + strReturn[1] + "')){this.disabled=true;__doPostBack('TransFor7netOld','');}", true);
                        }

                        return;
                    }
                    else
                    {
                        string SessionIDName = string.Format("{0}_{1}_7net", PageProgramCode, PageTimeStamp.Value);

                        bResult = ImportDocument(File_Path_Name);

                        if (bResult == false)
                        {
                            strReturn[0] = "2";
                            strReturn[1] = "文字檔資料格式錯誤,可按右方按鈕匯出錯誤資料。";


                        }
                        else
                        {
                            DataTable dt1 = new DataTable();
                            dt1 = (DataTable)Session[SessionIDName];

                            strReturn = bco.Insert7net(dt1, null);

                            if (!MoveFileToBackup())
                            {
                                strReturn[0] = "2";
                                strReturn[1] = "7net交易結轉失敗";
                            }
                        }
                    }
                }
                else if (rblCntType.SelectedValue == "3")
                {
                    ParameterList.Clear();

                    ParameterList.Add(SLP_YearMonth1.Text);
                    ParameterList.Add(rblCntType.SelectedValue);
                    ParameterList.Add("VAM23");
                    ParameterList.Add(Session["UID"].ToString());

                    strReturn = bco.CreateVdsVamSalesClear(ParameterList, null);
                }
                #endregion
            }
        }
        catch (Exception ex)
        {
            strReturn[0] = "2";
            strReturn[1] = ex.Message;
        }
        #endregion

        if (strReturn[0] == "2")
        {
            ErrorMsgLabel.Text = strReturn[1];
        }
    }
Пример #6
0
    public void UnSet()
    {
        #region

        string[] strReturn = new string[2];
        strReturn[0] = "";
        strReturn[1] = "";

        try
        {
            DateTime dateA;
            if (SLP_YearMonth1.Text.Length != 6)
            {
                strReturn[0] = "2";
                strReturn[1] = "年月格式有誤,請重新輸入";
            }
            else if (DateTime.TryParse(SLP_YearMonth1.Text.Substring(0, 4) + "/" + SLP_YearMonth1.Text.Substring(4, 2) + "/01", out dateA) == false)
            {
                strReturn[0] = "2";
                strReturn[1] = "年月格式有誤,請重新輸入";
            }
            else
            {
                #region
                BCO.VAM23_BCO bco = new BCO.VAM23_BCO(ConntionDB);
                ArrayList ParameterList = new ArrayList();
                ParameterList.Clear();

                ParameterList.Add(SLP_YearMonth1.Text);
                ParameterList.Add(rblCntType.SelectedValue);
                ParameterList.Add("VAM23");
                ParameterList.Add(Session["UID"].ToString());

                strReturn = bco.UnSetMonthClose(ParameterList, null);
                #endregion
            }
        }
        catch (Exception ex)
        {
            strReturn[0] = "2";
            strReturn[1] = ex.Message;
        }
        #endregion

        if (strReturn[0] == "2")
        {
            ErrorMsgLabel.Text = strReturn[1];
        }
    }
Пример #7
0
    private string[] ChkMonthClose(string sYM, string CntType, string sEXECUTE_NOTE, string UserID)
    {
        #region

        string[] strReturn = new string[2];
        strReturn[0] = "";
        strReturn[1] = "";

        try
        {
            DateTime dateA;
            if (sYM.Length != 6)
            {
                strReturn[0] = "2";
                strReturn[1] = "年月格式有誤,請重新輸入";
            }
            else if (DateTime.TryParse(sYM.Substring(0, 4) + "/" + sYM.Substring(4, 2) + "/01", out dateA) == false)
            {
                strReturn[0] = "2";
                strReturn[1] = "年月格式有誤,請重新輸入";
            }
            else
            {
                #region 取得資料
                BCO.VAM23_BCO bco = new BCO.VAM23_BCO(ConntionDB);
                ArrayList ParameterList = new ArrayList();
                ParameterList.Clear();

                ParameterList.Add(sYM);
                ParameterList.Add(CntType);
                ParameterList.Add("VAM23");
                ParameterList.Add(sEXECUTE_NOTE);
                ParameterList.Add(UserID);

                strReturn = bco.VendorMonthCloseYN(ParameterList,null);
                #endregion
            }

            return strReturn;
        }
        catch (Exception ex)
        {
            strReturn[0] = "2";
            strReturn[1] = ex.Message;
            return strReturn;
        }
        #endregion
    }