Example #1
0
        public void SetFalseALLAd()
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(pathfile);


                XmlElement node1 = xmlDoc.SelectSingleNode("/app/ad1") as XmlElement;
                node1.InnerText = "false";

                XmlElement node2 = xmlDoc.SelectSingleNode("/app/ad2") as XmlElement;
                node2.InnerText = "false";
                XmlElement node3 = xmlDoc.SelectSingleNode("/app/ad3") as XmlElement;
                node3.InnerText = "false";
                XmlElement node4 = xmlDoc.SelectSingleNode("/app/ad4") as XmlElement;
                node4.InnerText = "false";
                XmlElement node5 = xmlDoc.SelectSingleNode("/app/ad5") as XmlElement;
                node5.InnerText = "false";
                XmlElement node6 = xmlDoc.SelectSingleNode("/app/ad6") as XmlElement;
                node6.InnerText = "false";
                XmlElement node7 = xmlDoc.SelectSingleNode("/app/ad7") as XmlElement;
                node7.InnerText = "false";
                XmlElement node8 = xmlDoc.SelectSingleNode("/app/ad8") as XmlElement;
                node8.InnerText = "false";
                xmlDoc.Save(pathfile);
                loadValuFromFile();
            }
            catch (Exception exception)
            {
                CTLError.WriteError("entyconfigfile SetvalueKey ", exception.Message);
                return;
            }
        }
Example #2
0
        public static bool UpdateDonDatHang(string id, decimal soluong, decimal thanhtien)
        {
            try
            {
                SQLHelper sqlHelper = new SQLHelper();
                string    sql       = string.Format(@"
                                                    UPDATE [" + Config._DBNameFrontEnd + @"].dbo.DonDatHang
                                                    SET
	                                                    SoLuong = {1},
	                                                    ThanhTien = {2}
                                                    WHERE id='{0}'", id,
                                                    soluong,
                                                    thanhtien);

                int kq = sqlHelper.GetExecuteNonQueryByCommand(sql);
                if (kq <= 0)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                CTLError.WriteError("UpdateDonDatHang ", ex.Message);
                return(false);

                throw;
            }
        }
Example #3
0
        private void loadThongTin(DataTable dt)
        {
            if (dt == null)
            {
                return;
            }
            try
            {
                if (dt.Rows.Count == 1)
                {
                    DataRow row = dt.Rows[0];
                    //labdiemmuahangChinhthuc.Text = row["DiemMuaHangDauNgay"].ToString();
                    //labdiemthuongChinhthuc.Text = row["DiemThuongDauNgay"].ToString();
                    //labdiemdasudungChinhThuc.Text = row["DiemDaSuDungDauNgay"].ToString();
                    //labdiemconlaiChinhthuc.Text = row["DiemConLaiDauNgay"].ToString();
                    //labdiemmuahangGhinhan.Text = row["DiemMuaHangTrongNgay"].ToString();
                    //labDiemThuongGhiNhan.Text = row["DiemThuongTrongNgay"].ToString();
                    //labDiemDaSuDungGhiNhan.Text = row["DiemDaSuDungTrongNgay"].ToString();
                    //labDiemConLaiGiNhan.Text = row["DiemConLaiTrongNgay"].ToString();
                    //labSoPhieuQuaTang.Text = (row["SoPhieuQTDaNhan"].ToString() == string.Empty)
                    //                             ? "0"
                    //                             : row["SoPhieuQTDaNhan"].ToString();
                    //labNgayIn.Text = DateTime.Now.ToString("dd/MM/yyyy");
                    //labDiemConLaiNamTruoc.Text = row["DiemNamTruoc"].ToString();
                    //labdiemmuahangchinhthucdenhet.Text =Convert.ToDateTime(row["Ngay"]).ToString("dd/MM/yyyy");
                }
            }
            catch (Exception ex)
            {
                CTLError.WriteError("FrmKiot LoadThongTin", ex.Message);
                return;

                throw;
            }
        }
Example #4
0
        public IntPtr GetHandbyControlIDByHand(IntPtr hand)
        {
            try
            {
                //Process[] p = Process.GetProcessesByName("MACAddressChanger");
                IntPtr mainhan = hand;
                List <WindowScrape.Types.HwndObject> arr, arr1, arr2, arr3, arr4;

                arr = WindowScrape.Types.HwndObject.GetWindows();
                int mainInt = -1;

                for (int i = 0; i < arr.Count; i++)
                {
                    if (arr[i].Hwnd == (IntPtr)mainhan)
                    {
                        mainInt = i;
                        break;
                    }
                }

                arr1 = arr[mainInt].GetChildren();



                return(arr1[0].Hwnd);
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Restar service !!!");
                CTLError.WriteError("GetHandbyControlID ", ex.Message);
                return(IntPtr.Zero);
            }
        }
Example #5
0
        public void CreateTableDonDatHang()
        {
            try
            {
                SQLHelper sqlHelper = new SQLHelper();
                string    sql       = string.Format(@"IF (Not EXISTS (SELECT * FROM [" + Config._DBNameFrontEnd + @"].INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}'))
                                                        BEGIN                    
                                                        CREATE TABLE [" + Config._DBNameFrontEnd + @"].dbo.DonDatHang (                                                          
                                                        [ID] [nvarchar](36) NOT NULL,
	                                                    [HoTen] [nvarchar](255) NULL,
	                                                    [DienThoai] [nvarchar](255) NULL,
	                                                    [DiaChi] [nvarchar](255) NULL,
	                                                    [SoLuong] [decimal](19, 2) NULL,
	                                                    [ThanhTien] [decimal](19, 2) NULL,
	                                                    [NgayTao] [datetime] NULL,
	                                                    [GhiChu] [nvarchar](255) NULL,
                                                    
                                                        ); END", "DonDatHang");
                int       resl      = sqlHelper.GetExecuteNonQueryByCommand(sql);
                return;
            }
            catch (Exception exception)
            {
                CTLError.WriteError("frmDonDathang CreateTableDonDatHang ", exception.Message);
                return;

                throw;
            }
        }
        public static bool UpdateHanDung(string SKU, int HanDung)
        {
            try
            {
                SQLHelper sqlHelper = new SQLHelper();
                string    sql       = string.Format(@"
                                                    UPDATE [" + Config._DBNameFrontEnd + @"].dbo.ScaleAdHanDung
                                                    SET
                                                        Node = '{2}',
	                                                    HanDung = {1}
	                                                    
                                                    WHERE SKU='{0}'", SKU,
                                                    HanDung, DateTime.Now.ToString("dd-MM-yy hhmmss")
                                                    );
                int kq = sqlHelper.GetExecuteNonQueryByCommand(sql);
                if (kq <= 0)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                CTLError.WriteError("CTLScaleHanDung UpdateHanDung ", ex.Message);
                return(false);

                throw;
            }
        }
        public static bool InsertScaleAdHanDung(EntityScaleAdHanDung hanDung)
        {
            try
            {
                SQLHelper sqlHelper = new SQLHelper();
                string    sql       = string.Format(@"INSERT INTO [" + Config._DBNameFrontEnd + @"].dbo.ScaleAdHanDung
                                                                (
	                                                                SKU,
	                                                                HanDung,
	                                                                Node
                                                                )
                                                                VALUES
                                                                (
	                                                                '{0}'/* SKU	*/,
	                                                                {1}/* HanDung	*/,
	                                                                '{2}'/* Node	*/
                                                                )", hanDung.SKU,
                                                    hanDung.HanDung,
                                                    hanDung.Node);
                sqlHelper.GetExecuteNonQueryByCommand(sql);
                return(true);
            }
            catch (Exception ex)
            {
                CTLError.WriteError("CTLScaleHanDung InsertScaleAdHanDung ", ex.Message);
                return(false);

                throw;
            }
        }
Example #8
0
        private void btSave_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                try
                {
                    EntityDonDatHang dh = new EntityDonDatHang();
                    dh.ID      = Guid.NewGuid().ToString();
                    dh.HoTen   = txthotenKH.Text;
                    dh.DT      = txtDienThoai.Text;
                    dh.DiaChi  = txtDiaChi.Text;
                    dh.GhiChu  = txtghichu.Text;
                    dh.NgayTao = DateTime.Now;
                    decimal soluong  = 0;
                    decimal tongtien = 0;
                    for (int i = 0; i < gridView1.DataRowCount; i++)
                    {
                        DataRow row = gridView1.GetDataRow(i);
                        soluong  += Convert.ToDecimal(row["SoLuong"]);
                        tongtien += Convert.ToDecimal(row["ThanhTien"]);
                    }
                    dh.SoLuong  = soluong;
                    dh.ThanTien = tongtien;
                    CTLDonDatHang.InsertDonDatHang(dh, (DataTable)GrDSSKU.DataSource);
                }
                catch (Exception ex)
                {
                    CTLError.WriteError("btSave_Click ", ex.Message);
                    return;

                    throw;
                }
            }
        }
Example #9
0
        public DataTable GetDataTable(string sql)
        {
            DataTable dt = new DataTable();

            try
            {
                if (this.Open())
                {
                    OdbcDataAdapter adapter = new OdbcDataAdapter(sql, _connection);
                    adapter.Fill(dt);
                }
            }
            catch (Exception ex)
            {
                CTLError.WriteError("TPSDataAccess GetData", ex.Message);
                return(null);

                throw new Exception(ex.Message);
            }
            finally
            {
                this.Close();
            }
            return(dt);
        }
 private void btexportExcell_Click(object sender, EventArgs e)
 {
     try
     {
         if (gridView1.DataRowCount <= 0)
         {
             InfoMessage.HienThi("Không có dữ liệu xuất file ", "Vui lòng load dữ liệu", "Thông báo",
                                 HinhAnhThongBao.THONGTIN, NutThongBao.DONGY);
             return;
         }
         SaveFileDialog saveFileDialog = new SaveFileDialog();
         saveFileDialog.Filter   = "*.xls|*.xls";
         saveFileDialog.FileName = "CheckSKU_CKTM" + DateTime.Now.ToString("ddMMyyyy") + ".xls";
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             GrDSPriceSKU.ExportToXls(saveFileDialog.FileName);
             InfoMessage.HienThi("Xuất file " + saveFileDialog.FileName + " thành công!!! ", "Export Excell", "Thanh Cong",
                                 HinhAnhThongBao.THANHCONG, NutThongBao.DONGY);
         }
     }
     catch (Exception exception)
     {
         CTLError.WriteError("Export excell file ", exception.Message);
         throw;
     }
 }
Example #11
0
        public void loadControl()
        {
            try
            {
                //load timer
                numtimertick.Value = Convert.ToDecimal(CTLConfig._timer);
                timer1.Enabled     = true;
                timer1.Interval    = (int)numtimertick.Value * 1000 * 60;
                timer1.Tick       += new EventHandler(timer1_Tick);

                txtfileLocal.Text = CTLConfig._pathfilelocal;
                txtpathFTP.Text   = CTLConfig._pathftp;
                //load default
                txtdefault.Text = CTLConfig._pathdefault;
                //load path file config
                txtpathfileconfig.Text = CTLConfig._pathdefault;
                //load list box
                DirectoryInfo droot = new DirectoryInfo(txtfileLocal.Text);
                foreach (DirectoryInfo d in droot.GetDirectories())
                {
                    listBox1.Items.Add(d.FullName);
                }
                //load list editor file
                loadFileConfig();
            }
            catch (Exception ex)
            {
                CTLError.WriteError("Loi LoadControl ", ex.Message);
                return;
            }
        }
Example #12
0
        public string GetPricecategory(string custnum)
        {
            string name = "";

            //OdbcConnection con = new OdbcConnection("DRIVER=Topspeed ODBC Driver;timeout=15;NullEmptyStr=N;Timefield=%Time%;Datefield=%Date%;Oem=N;Extension=tps;DBQ=" + Path.Combine(CTLConfig._pathfileWinDSS, ""));
            try
            {
                this.Open();
                OdbcCommand cmd = new OdbcCommand();
                cmd.Connection  = _connection;
                cmd.CommandText = string.Format("Select Pricecategory from CUST where MCUSTNUM =" + custnum);
                cmd.CommandType = CommandType.Text;
                //OdbcParameter Ptungay = new OdbcParameter("@tungay", OdbcType.BigInt);
                //Ptungay.Value = tungay.ToOADate();
                //_cmdObj.Parameters.Add(Ptungay);
                //OdbcParameter Pdenngay = new OdbcParameter("@denngay", OdbcType.BigInt);
                //Pdenngay.Value = denngay.ToOADate();
                //_cmdObj.Parameters.Add(Pdenngay);
                name = cmd.ExecuteScalar().ToString();
            }
            catch (Exception ex)
            {
                CTLError.WriteError("TPSDataAccess GetPricecategory", ex.Message);
                return("0");

                throw;
            }
            finally
            {
                _connection.Close();
            }
            return(name);
        }
Example #13
0
        public static DataTable SearchCTDDH(string id)
        {
            try
            {
                DataTable dt        = new DataTable();
                SQLHelper sqlHelper = new SQLHelper();
                string    sql       = string.Format(@"SELECT cdh.ID,
                                                   cdh.SKU,
                                                   cdh.IDDonDatHang,
                                                   cdh.UPC,
                                                   cdh.TenSP,
                                                   cdh.SoLuong,
                                                   cdh.GiaGoc,
                                                   cdh.ThanhTien,
                                                   cdh.GiaKM,
                                                   cdh.GhiChu
                                            FROM   [" + Config._DBNameFrontEnd + @"].dbo.CTDonDatHang cdh
		                                            INNER JOIN ["         + Config._DBNameFrontEnd + @"].dbo.DonDatHang ddh
		                                            ON ddh.ID=cdh.IDDonDatHang
                                            WHERE cdh.IDDonDatHang= '{0}'", id);
                dt = sqlHelper.GetDatasetByCommand(sql).Tables[0];
                return(dt);
            }
            catch (Exception ex)
            {
                CTLError.WriteError("SearchCTDDH where ID ", ex.Message);
                return(null);

                throw;
            }
        }
Example #14
0
 public void checkconnect()
 {
     try
     {
         uint          num2;
         Process       process = Process.GetProcessesByName("openvpn-gui")[0];
         int           num     = 0;
         string        str     = DateTime.Now.ToString();
         IntPtr        windowThreadProcessId = (IntPtr)GetWindowThreadProcessId(process.Handle, out num2);
         string        str2     = "Current State: Connecting";
         StringBuilder lpString = new StringBuilder(50);
         GetWindowText(windowThreadProcessId, lpString, 50);
         while ((lpString.ToString().Trim() != str2) && (num < 10))
         {
             Thread.Sleep(0x3e8);
             GetWindowText(windowThreadProcessId, lpString, 50);
             num++;
         }
         if (num == 10)
         {
             str = str + " *********** Faile";
             this.ConnectOVPN();
         }
         else
         {
             str = str + " ---------- OK";
         }
         this.labtimecheck.Text = str;
         this.Refresh();
     }
     catch (Exception exception)
     {
         CTLError.WriteError("check connect loi ....", exception.Message);
     }
 }
Example #15
0
        public byte[] DownloadFile(string source)
        {
            //Logger.Debug("Đọc các tập tin trên FTP:{0}", source);
            CTLError.WriteError(string.Format("Đọc các tập tin trên FTP:{0}", source), "");
            FtpWebRequest req = (FtpWebRequest)WebRequest.Create(ftpRootPath + source);

            req.Credentials = new NetworkCredential(ftpUserName, ftpPassword);
            req.Method      = WebRequestMethods.Ftp.DownloadFile;
            req.UseBinary   = true;
            try
            {
                FtpWebResponse response = (FtpWebResponse)req.GetResponse();
                using (Stream ftpStream = response.GetResponseStream())
                    using (var memoryStream = new MemoryStream())
                    {
                        StreamExtensions.CopyTo(ftpStream, memoryStream);
                        //ftpStream.CopyTo(memoryStream);
                        //CopyTo(ftpStream, memoryStream);
                        response.Close();
                        req.Abort();
                        return(memoryStream.ToArray());
                    }
            }
            catch (Exception e)
            {
                //Logger.Warn("Đã xảy ra lỗi khi đọc tệp!{0}", e.Message);
                req.Abort();
                return(null);
            }
        }
Example #16
0
        public DataTable getDataFromXLS2007(string strFilePath)
        {
            DataTable table2;

            try
            {
                OleDbConnection connection = new OleDbConnection(this.connectionString.Replace("{sourcefile}", strFilePath));
                connection.Open();
                OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet1$A1:C100000]", connection);
                command.CommandTimeout = 0;
                OleDbDataAdapter adapter = new OleDbDataAdapter();
                adapter.SelectCommand = command;
                DataTable dataTable = new DataTable();
                adapter.Fill(dataTable);
                connection.Close();
                adapter = null;
                table2  = dataTable;
                table2.Columns.Add("NgayModify");
                table2.Columns.Add("Image", typeof(System.Byte[]));
            }
            catch (Exception exception)
            {
                CTLError.WriteError("CTLImportExcel GetDataFromXLS2007", exception.Message);
                return(null);

                throw new Exception(exception.Message);
            }
            return(table2);
        }
Example #17
0
 public void setvalueEnty()
 {
     try
     {
         _enty.ad1_ggban       = gban.Checked.ToString().ToLower();
         _enty.ad2_ggfull      = gfull.Checked.ToString().ToLower();
         _enty.ad3_amaz        = amz.Checked.ToString().ToLower();
         _enty.ad4_adcolony    = colony.Checked.ToString().ToLower();
         _enty.ad5_unity       = utity.Checked.ToString().ToLower();
         _enty.ad6_revmob      = rev.Checked.ToString().ToLower();
         _enty.ad7_vungle      = vule.Checked.ToString().ToLower();
         _enty.ad8_suppersonic = sonic.Checked.ToString().ToLower();
         _enty.gbanner         = txtgban.Text;
         _enty.gful            = txtgfull.Text;
         _enty.amazon          = txtamz.Text;
         _enty.adcolonyAppID   = txtcolonyID.Text;
         _enty.adcolonyZoneID  = txtcolonyzone.Text;
         _enty.unityid         = txtutity.Text;
         _enty.revmobid        = txtrev.Text;
         _enty.vungleid        = txtvule.Text;
         _enty.sonicid         = txtsonic.Text;
     }
     catch (Exception ex)
     {
         CTLError.WriteError("setvalueEnty ", ex.Message);
         return;
     }
 }
Example #18
0
        public void copyfile(string path)
        {
            if (path.Contains(@"D:\") || path.Contains(@"d:\"))
            {
                _PathFileINVMST = Path.Combine(path, "INVMST.tps");
                return;
            }

            try
            {
                //FileInfo fINV = new FileInfo(@"C:\WINDOWS\Temp\INVMST.tps");
                //if (fINV.Exists && fINV.LastWriteTime.ToString("dd/MM/yyyy") == DateTime.Now.ToString("dd/MM/yyyy"))
                //{
                //    _PathFileINVMST = @"C:\WINDOWS\Temp\INVMST.tps";
                //    return;
                //}
                FileInfo      fileInfo      = new FileInfo(Path.Combine(Config._pathfileWinDSS, "INVMST.tps"));
                DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\WINDOWS\Temp");
                if (!directoryInfo.Exists)
                {
                    directoryInfo.Create();
                }
                fileInfo.CopyTo(@"C:\WINDOWS\Temp\INVMST.tps", true);
                _PathFileINVMST = @"C:\WINDOWS\Temp\INVMST.tps";
            }
            catch (Exception ex)
            {
                CTLError.WriteError("Loi copy", ex.Message);
                _PathFileINVMST = Path.Combine(path, "INVMST.tps");
                throw;
            }
        }
Example #19
0
        public DataTable LoadTableKey(string filename)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("Name");
                dt.Columns.Add("Key");
                StreamReader read = new StreamReader(filename);
                while (!read.EndOfStream)
                {
                    string   s   = read.ReadLine();
                    string[] str = s.Split(new string[] { txtsplit.Text }, StringSplitOptions.None);
                    if (str.Length > 1)
                    {
                        DataRow r = dt.NewRow();
                        r["Name"] = str[0].Trim();
                        r["Key"]  = str[1].Trim();
                        dt.Rows.Add(r);
                    }
                }

                return(dt);
            }
            catch (Exception ex) { CTLError.WriteError("loi LoadTableKey ", ex.Message); return(null); }
        }
Example #20
0
        //code cu gen random ad all in config file

        public void SetTrueFalseAD(string pathFile)
        {
            try
            {
                foreach (string s in CTLConfig._GenAd)
                {
                    entyconfigfile enty = new entyconfigfile(pathFile);
                    enty.loadValuFromFile();
                    enty.SetvalueKey(s, "false");
                }
                //setamazon
                entyconfigfile entyama = new entyconfigfile(pathFile);
                entyama.loadValuFromFile();
                entyama.SetvalueKey("ad3", "true");

                Random ran       = new Random();
                int    CountTrue = ran.Next(1, CTLConfig._GenAd.Count);
                for (int i = 0; i < CountTrue; i++)
                {
                    Random         ran1  = new Random();
                    int            index = ran1.Next(0, CTLConfig._GenAd.Count);
                    entyconfigfile enty  = new entyconfigfile(pathFile);
                    enty.loadValuFromFile();
                    enty.SetvalueKey(CTLConfig._GenAd[index], "true");
                }
            }
            catch (Exception ex)
            {
                CTLError.WriteError("loi SetTrueFalseAD " + pathFile, ex.Message);
                MessageBox.Show("Loi " + pathFile + ex.Message);
            }
        }
Example #21
0
 public void SetValueFile(string pathFile)
 {
     try
     {
         FileInfo FileSource = new FileInfo(pathFile);
         foreach (string s in CTLConfig._Gentypead)
         {
             FileInfo f = new FileInfo(Path.Combine(CTLConfig._pathfilelocal, s.Trim() + FileSource.Name.Split('.')[0]));
             if (f.Exists)
             {
                 StreamReader  read = new StreamReader(f.FullName);
                 List <string> temp = new List <string>();
                 while (!read.EndOfStream)
                 {
                     string str = read.ReadLine();
                     if (str != string.Empty)
                     {
                         temp.Add(str);
                     }
                 }
                 Random         ran   = new Random();
                 int            index = ran.Next(0, temp.Count);
                 entyconfigfile enty  = new entyconfigfile(pathFile);
                 enty.loadValuFromFile();
                 enty.SetvalueKey(s, temp[index]);
             }
         }
     }
     catch (Exception ex)
     {
         CTLError.WriteError("loi SetValueFile " + pathFile, ex.Message);
         MessageBox.Show("Loi " + pathFile + ex.Message);
     }
 }
Example #22
0
        private void CreateFtpDirectory(string destFilePath)
        {
            string fullDir = FtpParseDirectory(destFilePath);

            string[] dirs   = fullDir.Split('/');
            string   curDir = "/";

            for (int i = 0; i < dirs.Length; i++)
            {
                string dir = dirs[i];
                if (dir != null && dir.Length > 0)
                {
                    try
                    {
                        curDir += dir + "/";
                        if (!CheckIfDirectoryExists(curDir))
                        {
                            MakeDirectory(curDir);
                        }
                    }
                    catch (Exception e)
                    {
                        //Logger.Error("Lỗi khi tạo thư mục FTP!", e);
                        CTLError.WriteError(string.Format("Lỗi khi tạo thư mục FTP!"), e.Message);
                    }
                }
            }
        }
Example #23
0
        public DataTable InfoCustommer(string makh)
        {
            DataSet ds = new DataSet();

            try
            {
                //mobj_SqlConnection.Open();
                using (SqlCommand cmd = new SqlCommand("sp_GET_CUSTOMER_INFO_AT_SUPERMARKET", mobj_SqlConnection))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@MaThe", makh);
                    cmd.Parameters.AddWithValue("@SoDienThoai", "");
                    cmd.Parameters.AddWithValue("@Ho", "");
                    cmd.Parameters.AddWithValue("@Ten", "");
                    SqlDataAdapter adpt = new SqlDataAdapter(cmd);
                    adpt.Fill(ds);
                }
                //mobj_SqlConnection.Close();
                if (ds.Tables.Count > 0)
                {
                    return(ds.Tables[0]);
                }
            }
            catch (Exception ex)
            {
                CTLError.WriteError("CTLConfig InFoCustommer", ex.Message);
                return(null);
            }
            return(null);
        }
Example #24
0
        //public Stream CopyTo(Stream input, Stream output)
        //{
        //    byte[] buffer = new byte[16 * 1024]; // Fairly arbitrary size
        //    int bytesRead;

        //    while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
        //    {
        //        output.Write(buffer, 0, bytesRead);
        //    }
        //    return out
        //}
        public bool DeleteFile(string source)
        {
            CTLError.WriteError(string.Format("Xóa các tập tin trên FTP:{0}", source), "");
            //Logger.Debug("Xóa các tập tin trên FTP:{0}", source);
            FtpWebRequest req = (FtpWebRequest)WebRequest.Create(ftpRootPath + source);

            req.Credentials = new NetworkCredential(ftpUserName, ftpPassword);
            req.Method      = WebRequestMethods.Ftp.DeleteFile;
            try
            {
                FtpWebResponse response = (FtpWebResponse)req.GetResponse();
                response.Close();
            }
            catch (Exception e)
            {
                //Logger.Warn("Đã xảy ra lỗi khi xóa tệp!{0}", e.Message);
                CTLError.WriteError(string.Format("Đã xảy ra lỗi khi xóa tệp!"), e.Message);
                req.Abort();
                return(false);
            }
            req.Abort();
            CTLError.WriteError(string.Format("Xóa thành công!"), "");
            //Logger.Debug("Xóa thành công!");
            return(true);
        }
Example #25
0
        public bool GoiEmailNhomWinDSS(string filenaem)
        {
            try
            {
                try
                {
                    SmtpClient emailClient1 = new SmtpClient("10.10.15.61", 25);
                    System.Net.NetworkCredential SMTPUserInfo1 = new System.Net.NetworkCredential("*****@*****.**", "@Nhnhatduy25");
                    emailClient1.UseDefaultCredentials = false;
                    MailAddress FromMail1 = new MailAddress("*****@*****.**", "Bao Cao Upload File T");
                    //emailClient.EnableSsl = true;
                    emailClient1.Credentials = SMTPUserInfo1;
                    //MailAddress FromMail1 = new MailAddress(CTLConfig._UserEmail, "IT SGC WinDSS");
                    MailMessage message1 = new MailMessage(FromMail1, new MailAddress("*****@*****.**"));
                    message1.Subject = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy");
                    message1.To.Add("*****@*****.**");
                    message1.To.Add("*****@*****.**");
                    message1.To.Add("*****@*****.**");

                    message1.Body = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy hh:mm:ss") + " file " + filenaem;
                    //System.Net.Mail.Attachment attachment;
                    //attachment = new System.Net.Mail.Attachment(Path.Combine(Application.StartupPath, DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy") + "_BaoCao.csv"));
                    //message1.Attachments.Add(attachment);
                    emailClient1.Send(message1);
                    return(true);
                }
                catch (Exception)
                {
                    SmtpClient emailClient1 = new SmtpClient("10.10.15.61", 25);
                    System.Net.NetworkCredential SMTPUserInfo1 = new System.Net.NetworkCredential("*****@*****.**", "@Nhnhatduy1");
                    emailClient1.UseDefaultCredentials = false;
                    MailAddress FromMail1 = new MailAddress("*****@*****.**", "Bao Cao Upload File T");
                    //emailClient.EnableSsl = true;
                    emailClient1.Credentials = SMTPUserInfo1;
                    //MailAddress FromMail1 = new MailAddress(CTLConfig._UserEmail, "IT SGC WinDSS");
                    MailMessage message1 = new MailMessage(FromMail1, new MailAddress("*****@*****.**"));
                    message1.Subject = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy hh:mm:ss") + " file " + filenaem;
                    message1.To.Add("*****@*****.**");
                    message1.To.Add("*****@*****.**");
                    message1.To.Add("*****@*****.**");

                    message1.Body = "Thông báo V/v upload File T strore " + _Store + " ngay " + Ngay.Value.ToString("dd-MM-yyyy");
                    //System.Net.Mail.Attachment attachment;
                    //attachment = new System.Net.Mail.Attachment(Path.Combine(Application.StartupPath, DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy") + "_BaoCao.csv"));
                    //message1.Attachments.Add(attachment);
                    emailClient1.Send(message1);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                CTLError.WriteError("Loi Khi Goi Email nhom WinDSS ", ex.Message);
                InfoMessage.HienThi("Vui long lien he voi voi Nhom WinDSS (Ex : 1081) ",
                                    "Loi Khi Goi Email nhom WDSS...", "Loi", HinhAnhThongBao.LOI, NutThongBao.DONGY);
                return(false);

                throw;
            }
        }
Example #26
0
 public void StartAPP(string path)
 {
     try
     {
         Process.Start(path);
     }
     catch (Exception ex)
     { CTLError.WriteError(" loi start app ", ex.Message); }
 }
Example #27
0
 public string getipproxy()
 {
     try
     {
         return(new WebClient().DownloadString("http://icanhazip.com"));
     }
     catch (Exception exception)
     {
         CTLError.WriteError("Loi GetIPProxy......", exception.Message);
         return("");
     }
 }
Example #28
0
        private void bttestcopy_Click(object sender, EventArgs e)
        {
            //test copy config
            try
            {
                _istestCopyConfig = true;

                ChangeOpenVpnConfig();

                _istestCopyConfig = false;
            }
            catch (Exception ex) { CTLError.WriteError("Loi testcopy config", ex.Message); }
        }
Example #29
0
        public static bool InsertCTDDH(EntityCTDonDatHang ct)
        {
            try
            {
                SQLHelper sqlHelper = new SQLHelper();
                string    sql       = string.Format(@"INSERT INTO [" + Config._DBNameFrontEnd + @"].dbo.CTDonDatHang
                                                                (
	                                                                ID,
	                                                                IDDonDatHang,
	                                                                SKU,
	                                                                UPC,
	                                                                TenSP,
	                                                                SoLuong,
	                                                                GiaGoc,
	                                                                ThanhTien,
	                                                                GiaKM,
	                                                                GhiChu
                                                                )
                                                                VALUES
                                                                (
	                                                                '{0}'/* ID	*/,
	                                                                '{1}'/* IDDonDatHang	*/,
	                                                                '{2}'/* SKU	*/,
	                                                                '{3}'/* UPC	*/,
	                                                                '{4}'/* TenSP	*/,
	                                                                {5}/* SoLuong	*/,
	                                                                {6}/* GiaGoc	*/,
	                                                                {7}/* ThanhTien	*/,
	                                                                {8}/* GiaKM	*/,
	                                                                '{9}'/* GhiChu	*/
                                                                )", ct.ID,
                                                    ct.IDDonDatHang,
                                                    ct.SKU,
                                                    ct.UPC,
                                                    ct.TenSP,
                                                    ct.SoLuong,
                                                    ct.GiaGoc,
                                                    ct.ThanTien,
                                                    ct.GiaKM,
                                                    ct.GhiChu);
                sqlHelper.GetExecuteNonQueryByCommand(sql);
                return(true);
            }
            catch (Exception ex)
            {
                CTLError.WriteError("InsertCTDDH ", ex.Message);
                return(false);

                throw;
            }
        }
Example #30
0
        public string UploadFile(string source)
        {
            CTLError.WriteError(string.Format("upload file : {0},FTP: {1}", source, ftpRootPath), "");
            //Logger.Debug("upload file : {0},FTP: {1}", source, ftpRootPath);
            //string fileName = GenerateFileName(source);
            string fileName = source;
            //Logger.Debug("file name: {0}", fileName);
            //CTLError.WriteError(string.Format("file name: {0}", fileName), "");
            var result = UploadFile(fileName, source);

            //Logger.Debug("Tải lên thành công! Trả lại đường dẫn tệp đến:{0}", fileName);
            //CTLError.WriteError(string.Format("Tải lên thành công! Trả lại đường dẫn tệp đến:{0}", fileName), "");
            return(result.ToString());
        }