Beispiel #1
0
 public Boolean CreateTextProductFile(string aFlag, MySqlDataReader aRead)
 {
     if (aFlag == "master")
     {
         MasterKingPower lsMaster = new MasterKingPower();
         if (lsGdb.Gdb.State == System.Data.ConnectionState.Closed)
         {
             lsGdb.ConnectDatabase();
         }
         if (lsIniT.TblMember.Count == 0)
         {
             lsIniT.CreateTblMember(lsGdb.Gdb);
         }
         if (lsIniT.TblNationality.Count == 0)
         {
             lsIniT.CreateTblNationality(lsGdb.Gdb);
         }
         if (lsIniT.TblCounter.Count == 0)
         {
             lsIniT.CreateTblCounter(lsGdb.Gdb);
         }
         if (lsIniT.TblShift.Count == 0)
         {
             lsIniT.CreateTblShift(lsGdb.Gdb);
         }
         if (lsIniT.TblTypeMem.Count == 0)
         {
             lsIniT.CreateTblTypeMem(lsGdb.Gdb);
         }
         if (lsIniT.TblTypeRoom.Count == 0)
         {
             lsIniT.CreateTblTypeRoom(lsGdb.Gdb);
         }
         //lsIniT.CreateTblInitial(lsGdb.Gdb);
         lsMaster.ShopCode = lsIni.GetString("kingpower", "shopcode", "0");
         string lsFileName = "", lsPath = "D://thahr30//";
         lsFileName     = lsMaster.ShopCode + "_Product_" + System.DateTime.Now.Year.ToString("0000") + System.DateTime.Now.Month.ToString("00") + System.DateTime.Now.Day.ToString("00") + System.DateTime.Now.Hour.ToString("00") + System.DateTime.Now.Minute.ToString("00") + System.DateTime.Now.Second.ToString("00");
         lsPath         = lsIni.GetString("kingpower", "pathtextfilekingpower", "D://thahr30//text//");
         lsTextFileName = lsPath + lsFileName + ".Txt";
         StreamWriter lsSW = new StreamWriter(lsPath + lsFileName + ".Txt");
         //KingPower lsGen = new KingPower();
         string[] lsData = new string[2000];
         lsData = GenMasterFileKingPower(aRead);
         //if (lsData[1] != "")
         //{
         //    MessageBox.Show("àµÃÕÂÁ¢éÍÁÙÅ·Ñé§ËÁ´ àÃÕºÃéÍÂ", "Prepare Data All", MessageBoxButtons.OK);
         //}
         lsSW.WriteLine("[Product]");
         foreach (string lsD in lsData)
         {
             if (lsD != null)
             {
                 lsSW.WriteLine(lsD);
             }
         }
         //lsSW.WriteLine(lsData);
         lsSW.Close();
     }
     return(true);
 }
Beispiel #2
0
        public void CreateTextProductFile(string[] aData, string aYYYYMMDDHHMMSS)
        {
            string lsFileName = "", lsPath = "D://thahr30//";

            try
            {
                MasterKingPower lsMaster = new MasterKingPower();
                lsPath            = lsIni.GetString("kingpower", "pathtextfilekingpower", "D://thahr30//text//");
                lsMaster.ShopCode = lsIni.GetString("kingpower", "shopcode", "0");
                //lsPath = lsIni.GetString("kingpower", "pathtextfilekingpower", "D://thahr30//");
                lsFileName     = lsMaster.ShopCode + "_Product_" + aYYYYMMDDHHMMSS.Substring(0, 4) + aYYYYMMDDHHMMSS.Substring(5, 2) + aYYYYMMDDHHMMSS.Substring(8, 8);
                lsTextFileName = lsPath + lsFileName + ".Txt";
                StreamWriter lsSW = new StreamWriter(lsPath + lsFileName + ".Txt");
                //lsSW.WriteLine("[Product]");
                foreach (string lsD in aData)
                {
                    if (lsD != null)
                    {
                        lsSW.WriteLine(lsD);
                    }
                }
                lsSW.Close();
            }
            catch (Exception e)
            {
                string ls = "äÁèÊÒÁÒöÊÃéÒ§ Text Fileä´é " + lsPath + lsFileName;
                lsGdb.WriteLogError(ls, e, "", "CreateTextFile");
                //MessageBox.Show(ls + " " + e.Message.ToString(), e.Source.ToString(), MessageBoxButtons.OK);
            }
        }
Beispiel #3
0
        private string[] GenMasterFileKingPower(MySqlDataReader aRead)
        {
            Int32  i = 0, j = 0;
            double ldoPriceStart;

            string[]        lsData = new string[3000];
            string          lsSQL = "", lsVouDate = "", lsDay = "", lsTRoomName = "";
            string          lsData1_10 = "", lsData11_23 = "", lsMemID = "", lsMemName = "";
            string          lsUserName = lsIni.GetString("thahr30", "username", "janepop");
            string          lsPassword = lsIni.GetString("thahr30", "password", "Ekartc2c5");
            string          lsServer   = lsIni.GetString("thahr30", "serverdatabasename", "localhost");
            string          lsDatabase = lsIni.GetString("thahr30", "databasename", "localhost");
            string          StrConn    = "Data Source=" + lsServer + ";Database=" + lsDatabase + ";User ID=" + lsUserName + ";Password="******"";
            MySqlConnection Conn       = new MySqlConnection(StrConn);
            MasterKingPower lsMaster   = new MasterKingPower();
            double          ldoMulti   = 0;

            try
            {
                //lsIniT.CreateTblTypeRoom(lsGdb.Gdb);
                lsMaster.ReVat         = 1.07;
                lsMaster.ShopCode      = lsIni.GetString("kingpower", "shopcode", "0");
                lsMaster.Std_Cate_Code = lsIni.GetString("kingpower", "std_cate_code", "0");
                lsMaster.Branch_Code   = lsIni.GetString("kingpower", "branch_code", "0");
                lsMaster.ShpBnd_Code   = lsIni.GetString("kingpower", "shpbnd_code", "0");
                lsMaster.Currency_code = lsIni.GetString("kingpower", "currency_code", "0");
                lsMaster.Rate          = lsIni.GetString("kingpower", "rate", "0");
                lsMaster.Unit_Code     = lsIni.GetString("kingpower", "unit_code", "0");
                lsMaster.VatRate       = lsIni.GetString("thahr30", "vatrate", "0");
                lsMaster.UStoBaht      = lsIni.GetString("thahr30", "USTOBAHT", "0");
                ldoMulti = Convert.ToDouble(lsIni.GetString("kingpower", "ratekingpower", "15.00"));
                //lsMaster.ReVat = lsMaster.Vat_Rate;
                Conn.Open();
                lsDay     = Convert.ToString(System.DateTime.Now.Day - 1);
                lsVouDate = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + lsDay;
                if (aRead.HasRows)
                {
                    //lsVat_Rate = lsMaster.lsVatRate;
                    lsMaster.Vat_Type     = lsIni.GetString("kingpower", "vat_type", "1");
                    lsMaster.ReQuest_Date = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00");
                    //lsMaster.ReQuest_Date = "2006-09-28";
                    lsMaster.Request_Exc_Vat  = "";
                    lsMaster.Request_Inc_Vat  = "";
                    lsMaster.RequestEFF_SDate = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00") + " " + System.DateTime.Now.Hour.ToString("00") + ":" + System.DateTime.Now.Minute.ToString("00") + ":" + System.DateTime.Now.Second.ToString("00");

                    /*if ((System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00") + " " + System.DateTime.Now.Hour.ToString("00") + ":" + System.DateTime.Now.Minute.ToString("00") + ":" + System.DateTime.Now.Second.ToString("00")) > (System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27 23:59:59"))
                     * {
                     *  lsMaster.RequestEFF_EDate = System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27 23:59:59";
                     *  lsMaster.Ref_Price_Date = "2006-09-27";
                     * }
                     * else
                     * {*/
                    lsMaster.RequestEFF_EDate = System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27 23:59:59";
                    lsMaster.Ref_Price_Date   = System.DateTime.Now.AddYears(1).Year.ToString("0000") + "-09-27";
                    //}
                    //lsMaster.RequestEFF_SDate = "2006-09-28 00:00:00";
                    //lsMaster.RequestEFF_EDate = "2011-09-27 23:59:59";
                    //lsMaster.RequestEFF_EDate = DateTime.Now.AddYears(1).tos;

                    lsMaster.Ref_Price     = "7.0";
                    lsMaster.Ref_Price_SRC = "Don Muang";
                    //lsMaster.Ref_Price_Date = "2006-09-27";
                    lsMaster.Ref_Code_1 = "";
                    lsMaster.Ref_Code_2 = "";
                    lsMaster.Ref_Code_3 = "";
                    lsMaster.Ref_Code_4 = "";
                    lsMaster.Ref_Code_5 = "";
                    while (aRead.Read())
                    {
                        lsMemID = aRead.GetValue(0).ToString();
                        if (lsMemID == "-")
                        {
                            lsSQL = "";
                        }
                        lsSQL = "select * From memberpricelist Where memid = '" + lsMemID + "' and flagsendkingpower = '1'";
                        MySqlCommand    Comm = new MySqlCommand(lsSQL, Conn);
                        MySqlDataReader Read;
                        Read = Comm.ExecuteReader();
                        if (Read.HasRows)
                        {
                            j = 0;
                            while (Read.Read())
                            {
                                i++;
                                if (Read["flagoldkingpower"].ToString() == "1")
                                {
                                    lsMaster.Trans_Type = "1";
                                }
                                else
                                {
                                    lsMaster.Trans_Type = "2";
                                }
                                lsSQL     = aRead.GetValue(1).ToString();
                                lsMemName = aRead.GetValue(1).ToString();
                                lsMaster.Ref_Price_SRC = lsMemName;
                                ldoPriceStart          = Convert.ToDouble(aRead.GetValue(12));
                                lsSQL = Convert.ToString(aRead.GetValue(12));
                                decimal cc = Convert.ToDecimal(aRead.GetValue(12));
                                //ldoPriceStart = (Convert.ToDouble(aRead.GetValue(12)) * Convert.ToDouble(lsMaster.UStoBaht));
                                if (Read["remark"].ToString() == "US$")
                                {
                                    ldoPriceStart = (Convert.ToDouble(Read["pricestart"]) * Convert.ToDouble(lsMaster.UStoBaht));
                                }
                                else
                                {
                                    ldoPriceStart = Convert.ToDouble(Read["pricestart"]);
                                }
                                ldoPriceStart = (ldoPriceStart * ldoMulti) / 100;
                                //decimal bbb = Convert.ToDecimal(ldoPriceStart);
                                decimal aa = decimal.Round(Convert.ToDecimal(ldoPriceStart * lsMaster.ReVat), 2); //lsMaster.Request_Inc_Vat = Convert.ToString(decimal.Round(Convert.ToDecimal(ldoPriceStart), 2));
                                //lsMaster.Request_Inc_Vat = ldoPriceStart.ToString("0.00");
                                //lsMaster.Vat_Type;
                                //lsMaster.Request_Inc_Vat = ldoPriceStart.ToString("0.00");
                                if (lsMaster.Vat_Type == "2")
                                {
                                    decimal aaa = Convert.ToDecimal(ldoPriceStart + (ldoPriceStart * Convert.ToDouble(lsMaster.VatRate) / 100));
                                    lsMaster.Request_Inc_Vat = aaa.ToString("0.00");
                                    lsMaster.Request_Exc_Vat = ldoPriceStart.ToString("0.00");
                                }
                                else
                                {
                                    lsMaster.Request_Inc_Vat = Convert.ToString(aa);
                                    lsMaster.Request_Exc_Vat = Convert.ToString(ldoPriceStart);
                                }
                                //lsMaster.Request_Inc_Vat = lsMaster.Request_Inc_Vat;
                                lsMaster.Ref_Price = lsMaster.Request_Exc_Vat;
                                lsTRoomName        = lsIniT.SelectInitial(lsIniT.TblTypeRoom, Read["plcode"].ToString(), Initial.WhereSelect.aCodetoName);
                                j++;
                                lsData1_10  = lsMaster.ShopCode + "|" + lsMaster.Std_Cate_Code + "|" + lsMemID + Read["plcode"].ToString() + "|" + lsMemName + "[" + lsTRoomName + "]" + "|" + lsMaster.ShpBnd_Code + "|" + lsMaster.BarCode + "|" + lsMaster.Trans_Type + "|" + lsMaster.Vat_Type + "|" + lsMaster.VatRate + "|" + lsMaster.Unit_Code;
                                lsData11_23 = lsMaster.ReQuest_Date + "|" + lsMaster.Request_Exc_Vat + "|" + lsMaster.Request_Inc_Vat + "|" + lsMaster.RequestEFF_SDate + "|" + lsMaster.RequestEFF_EDate + "|" + lsMaster.Ref_Price + "|" + lsMaster.Ref_Price_SRC + "|" + lsMaster.Ref_Price_Date + "|" + lsMaster.Ref_Code_1 + "|" + lsMaster.Ref_Code_2 + "|" + lsMaster.Ref_Code_3 + "|" + lsMaster.Ref_Code_4 + "|" + lsMaster.Ref_Code_5;
                                lsData[i]   = lsData1_10 + "|" + lsData11_23;
                            }
                        }
                        Read.Close();
                    }
                }
                Conn.Close();
            }
            catch (Exception e)
            {
                string ls = "äÁèÊÒÁÒöàµÃÕÂÁ¢éÍÁÙÅ Print ä´é ";
                lsGdb.WriteLogError(ls, e, "", "GenMasterFileKingPower ");
                //MessageBox.Show(ls + " " + eAcc.Message.ToString(), eAcc.Source.ToString(), MessageBoxButtons.OK);
            }
            return(lsData);
        }
Beispiel #4
0
        private string[] GenMasterFileKingPower(MySqlDataReader aRead, double aPriceBaht)
        {
            MasterKingPower lsMaster = new MasterKingPower();

            if (lsGdb.Gdb.State == System.Data.ConnectionState.Closed)
            {
                lsGdb.ConnectDatabase();
            }
            lsIniT.CreateTblMember(lsGdb.Gdb);
            lsIniT.CreateTblNationality(lsGdb.Gdb);
            lsIniT.CreateTblCounter(lsGdb.Gdb);
            lsIniT.CreateTblShift(lsGdb.Gdb);
            lsIniT.CreateTblTypeMem(lsGdb.Gdb);
            lsMaster.ReVat         = 1.07;
            lsMaster.ShopCode      = lsIni.GetString("kingpower", "shopcode", "0");
            lsMaster.Std_Cate_Code = lsIni.GetString("kingpower", "std_cate_code", "0");
            lsMaster.Branch_Code   = lsIni.GetString("kingpower", "branch_code", "0");
            lsMaster.ShpBnd_Code   = lsIni.GetString("kingpower", "shpbnd_code", "0");
            lsMaster.Currency_code = lsIni.GetString("kingpower", "currency_code", "0");
            lsMaster.Rate          = lsIni.GetString("kingpower", "rate", "0");
            lsMaster.Unit_Code     = lsIni.GetString("kingpower", "unit_code", "0");
            lsMaster.VatRate       = lsIni.GetString("thahr30", "vatrate", "0");
            lsMaster.UStoBaht      = lsIni.GetString("thahr30", "USTOBAHT", "0");
            Int32  i = 0;
            double ldoPriceStart, ldoPriceEnd;

            string[] lsData = new string[2000];
            string   lsSQL = "", lsVouDate = "", lsDay = "";
            string   lsData1_10 = "", lsData11_23 = "", lsMemID = "", lsMemName = "";

            lsDay     = Convert.ToString(System.DateTime.Now.Day - 1);
            lsVouDate = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + lsDay;
            if (aRead.HasRows)
            {
                //lsVat_Rate = lsMaster.lsVatRate;
                lsMaster.Vat_Type     = lsIni.GetString("kingpower", "vat_type", "1");
                lsMaster.ReQuest_Date = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00");

                lsMaster.Request_Exc_Vat  = "";
                lsMaster.Request_Inc_Vat  = "";
                lsMaster.RequestEFF_SDate = System.DateTime.Now.Year.ToString("0000") + "-" + System.DateTime.Now.Month.ToString("00") + "-" + System.DateTime.Now.Day.ToString("00") + " " + System.DateTime.Now.Hour.ToString("00") + ":" + System.DateTime.Now.Minute.ToString("00") + ":" + System.DateTime.Now.Second.ToString("00");
                lsMaster.RequestEFF_SDate = "2006-09-28 00:00:00";
                lsMaster.RequestEFF_EDate = "2011-09-27 23:59:59";
                lsMaster.Ref_Price        = "7.0";
                lsMaster.Ref_Price_SRC    = "Don Muang";
                lsMaster.Ref_Price_Date   = "2006-09-27";
                lsMaster.Ref_Code_1       = "";
                lsMaster.Ref_Code_2       = "";
                lsMaster.Ref_Code_3       = "";
                lsMaster.Ref_Code_4       = "";
                lsMaster.Ref_Code_5       = "";
                while (aRead.Read())
                {
                    i++;
                    lsMaster.Trans_Type = "1";
                    lsMemID             = aRead.GetValue(0).ToString();
                    lsSQL     = aRead.GetValue(1).ToString();
                    lsMemName = aRead.GetValue(1).ToString();
                    lsMaster.Ref_Price_SRC = lsMemName;
                    ldoPriceStart          = Convert.ToDouble(aRead.GetValue(12));
                    lsSQL = Convert.ToString(aRead.GetValue(12));
                    decimal cc = Convert.ToDecimal(aRead.GetValue(12));
                    ldoPriceStart = (Convert.ToDouble(aRead.GetValue(12)) * Convert.ToDouble(lsMaster.UStoBaht));
                    //ldoPriceStart = decimal.Round(ldoPriceStart, 2);
                    //decimal bbb = Convert.ToDecimal(ldoPriceStart);
                    decimal aa = decimal.Round(Convert.ToDecimal(ldoPriceStart / lsMaster.ReVat), 2);                        //lsMaster.Request_Inc_Vat = Convert.ToString(decimal.Round(Convert.ToDecimal(ldoPriceStart), 2));
                    lsMaster.Request_Inc_Vat = ldoPriceStart.ToString("0.00");
                    lsMaster.Request_Exc_Vat = Convert.ToString(aa);
                    //lsMaster.Request_Inc_Vat = lsMaster.Request_Inc_Vat;
                    lsMaster.Ref_Price = lsMaster.Request_Exc_Vat;
                    if (lsMemID == lsMem)
                    {
                        j++;
                    }
                    else
                    {
                        lsMem = lsMemID;
                        j     = 1;
                    }
                    ldoPriceEnd = aPriceBaht;
                    decimal bb = decimal.Round(Convert.ToDecimal(ldoPriceEnd / lsMaster.ReVat), 2);

                    //lsMaster.Request_Inc_Vat = Convert.ToString(decimal.Round(Convert.ToDecimal(ldoPriceEnd), 2));
                    lsMaster.Request_Inc_Vat = ldoPriceEnd.ToString("0.00");
                    lsMaster.Request_Exc_Vat = Convert.ToString(bb);
                    //lsMaster.Request_Inc_Vat = lsMaster.Request_Inc_Vat;
                    lsMaster.Ref_Price = lsMaster.Request_Exc_Vat;
                    lsData1_10         = lsMaster.ShopCode + "|" + lsMaster.Std_Cate_Code + "|" + lsMemID + j.ToString("00000") + "|" + lsMemName + "|" + lsMaster.ShpBnd_Code + "|" + lsMaster.BarCode + "|" + lsMaster.Trans_Type + "|" + lsMaster.Vat_Type + "|" + lsMaster.VatRate + "|" + lsMaster.Unit_Code;
                    lsData11_23        = lsMaster.ReQuest_Date + "|" + lsMaster.Request_Exc_Vat + "|" + lsMaster.Request_Inc_Vat + "|" + lsMaster.RequestEFF_SDate + "|" + lsMaster.RequestEFF_EDate + "|" + lsMaster.Ref_Price + "|" + lsMaster.Ref_Price_SRC + "|" + lsMaster.Ref_Price_Date + "|" + lsMaster.Ref_Code_1 + "|" + lsMaster.Ref_Code_2 + "|" + lsMaster.Ref_Code_3 + "|" + lsMaster.Ref_Code_4 + "|" + lsMaster.Ref_Code_5;
                    lsData[i]          = lsData1_10 + "|" + lsData11_23;
                    //lsSW.WriteLine(lsData);
                    //lsSW.WriteLine(lsData);
                }
            }
            return(lsData);
        }