Esempio n. 1
0
        public bool Delete(Entities.TheVip thevip)
        {
            bool trave = false;

            try
            {
                string sql = new Common.Constants.Sql().deleteTheVip;
                conn = new Connection();
                Constants.TheVip tv = new Constants.TheVip();
                cn  = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value = thevip.MaThe.ToUpper();
                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    trave = true;
                }
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                trave = false;
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(trave);
        }
Esempio n. 2
0
        private void frmSQL_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (i == 0)
                {
                    i = 1;

                    if (Luu.Server == "server")
                    {
                        Common.Constants.Sql data = new Common.Constants.Sql();
                        string           Links    = Application.StartupPath.ToString() + data.ConfigXML;
                        Common.Utilities com      = new Common.Utilities();
                        if (com.CheckFile(Links) == true)
                        {
                            Entities.SQL sql = new SQL();
                            sql = com.ConnectionsName();
                            _connectionString = "Data Source=" + sql.ServerName
                                                + ";User ID=" + sql.UserName
                                                + ";password="******";Initial Catalog=" + sql.DatabaseName;

                            if (CheckDatabase("SupermarketManagementDHT") == true)
                            {
                                if (!Luu.KFULL)
                                {
                                    loginOK();
                                }
                            }
                            else
                            {
                                SelectServerName();
                            }
                        }
                        else
                        {
                            SelectServerName();
                        }
                    }
                    else
                    {
                        if (Luu.Server == "client")
                        {
                            loginOK();
                        }
                        else
                        {
                            MessageBox.Show("Kiểm tra lại file xml");
                        }
                    }
                }
            }
            catch
            { }
        }
Esempio n. 3
0
 public Entities.TheVip[] Select(Entities.TheVip thevip)
 {
     Entities.TheVip[] arrC = null;
     try
     {
         string           sql = new Common.Constants.Sql().selectTheVipAll;
         Constants.TheVip tv  = new Constants.TheVip();
         conn = new Connection();
         cn   = conn.openConnection();
         cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
         dr  = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.TheVip tao = new Entities.TheVip();
             tao.MaKhachHang  = dr[tv.MaKhachHang].ToString().ToUpper();
             tao.MaThe        = dr[tv.MaThe].ToString().ToUpper();
             tao.GiaTriThe    = dr[tv.GiaTriThe].ToString();
             tao.GiaTriConLai = dr[tv.GiaTriConLai].ToString();
             tao.GhiChu       = dr[tv.GhiChu].ToString();
             tao.SoDiem       = dr[tv.SoDiem].ToString();
             tao.Deleted      = (bool)dr[tv.Deleted];
             arr.Add(tao);
         }
         //int n = arr.Count;
         //if (n == 0) { arrC = null; }
         //arrC = new Entities.TheVip[n];
         //for (int i = 0; i < n; i++)
         //{
         //    arrC[i] = (Entities.TheVip)arr[i];
         //}
         if (arr.Count > 0)
         {
             arrC = (Entities.TheVip[])arr.ToArray(typeof(Entities.TheVip));
         }
         else
         {
             return(new Entities.TheVip[0]);
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); arrC = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return(arrC);
 }
Esempio n. 4
0
        public bool Insert(Entities.TheVip thevip)
        {
            bool trave = false;

            try
            {
                string sql = new Common.Constants.Sql().insertTheVip;
                conn = new Connection();
                Constants.TheVip tv = new Constants.TheVip();
                cn  = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
                cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value       = thevip.MaThe.ToUpper();
                cmd.Parameters.Add(tv.GiaTriThe, SqlDbType.Float).Value         = thevip.GiaTriThe;
                cmd.Parameters.Add(tv.GiaTriConLai, SqlDbType.Float).Value      = thevip.GiaTriConLai;
                cmd.Parameters.Add(tv.GhiChu, SqlDbType.VarChar, 100).Value     = thevip.GhiChu;
                cmd.Parameters.Add(tv.SoDiem, SqlDbType.VarChar, 100).Value     = thevip.SoDiem;

                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    trave = true;
                }
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                trave = false;
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(trave);
        }
Esempio n. 5
0
        public bool Delete(Entities.TheVip thevip)
        {
            bool trave = false;
            try
            {

                string sql = new Common.Constants.Sql().deleteTheVip;
                conn = new Connection();
                Constants.TheVip tv = new Constants.TheVip();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value = thevip.MaThe.ToUpper();
                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    trave = true;
                }
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();

            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                trave = false;
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();

            }
            return trave;
        }
Esempio n. 6
0
        public bool Insert(Entities.TheVip thevip)
        {
            bool trave = false;
            try
            {

                string sql = new Common.Constants.Sql().insertTheVip;
                conn = new Connection();
                Constants.TheVip tv = new Constants.TheVip();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
                cmd.Parameters.Add(tv.MaThe, SqlDbType.VarChar, 50).Value = thevip.MaThe.ToUpper();
                cmd.Parameters.Add(tv.GiaTriThe, SqlDbType.Float).Value = thevip.GiaTriThe;
                cmd.Parameters.Add(tv.GiaTriConLai, SqlDbType.Float).Value = thevip.GiaTriConLai;
                cmd.Parameters.Add(tv.GhiChu, SqlDbType.VarChar, 100).Value = thevip.GhiChu;
                cmd.Parameters.Add(tv.SoDiem, SqlDbType.VarChar, 100).Value = thevip.SoDiem;

                int i = cmd.ExecuteNonQuery();
                if (i == 1)
                {
                    trave = true;
                }
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();

            }
            catch (Exception ex)
            {
                string s = ex.Message.ToString();
                trave = false;
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();

            }
            return trave;
        }
Esempio n. 7
0
 public Entities.TheVip[] Select(Entities.TheVip thevip)
 {
     Entities.TheVip[] arrC = null;
     try
     {
         string sql = new Common.Constants.Sql().selectTheVipAll;
         Constants.TheVip tv = new Constants.TheVip();
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(tv.MaKhachHang, SqlDbType.VarChar, 50).Value = thevip.MaKhachHang.ToUpper();
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.TheVip tao = new Entities.TheVip();
             tao.MaKhachHang = dr[tv.MaKhachHang].ToString().ToUpper();
             tao.MaThe = dr[tv.MaThe].ToString().ToUpper();
             tao.GiaTriThe = dr[tv.GiaTriThe].ToString();
             tao.GiaTriConLai = dr[tv.GiaTriConLai].ToString();
             tao.GhiChu = dr[tv.GhiChu].ToString();
             tao.SoDiem = dr[tv.SoDiem].ToString();
             tao.Deleted = (bool)dr[tv.Deleted];
             arr.Add(tao);
         }
         //int n = arr.Count;
         //if (n == 0) { arrC = null; }
         //arrC = new Entities.TheVip[n];
         //for (int i = 0; i < n; i++)
         //{
         //    arrC[i] = (Entities.TheVip)arr[i];
         //}
         if (arr.Count > 0)
         {
             arrC = (Entities.TheVip[])arr.ToArray(typeof(Entities.TheVip));
         }
         else
             return new Entities.TheVip[0];
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); arrC = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return arrC;
 }
Esempio n. 8
0
        private void frmSQL_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (i == 0)
                {
                    i = 1;

                    if (Luu.Server == "server")
                    {
                        Common.Constants.Sql data = new Common.Constants.Sql();
                        string Links = Application.StartupPath.ToString() + data.ConfigXML;
                        Common.Utilities com = new Common.Utilities();
                        if (com.CheckFile(Links) == true)
                        {
                            Entities.SQL sql = new SQL();
                            sql = com.ConnectionsName();
                            _connectionString = "Data Source=" + sql.ServerName
                                + ";User ID=" + sql.UserName
                                + ";password="******";Initial Catalog=" + sql.DatabaseName;

                            if (CheckDatabase("SupermarketManagementDHT") == true)
                            {
                                if (!Luu.KFULL)
                                {
                                    loginOK();
                                }
                            }
                            else
                            {
                                SelectServerName();
                            }
                        }
                        else
                        { SelectServerName(); }
                    }
                    else
                    {

                        if (Luu.Server == "client")
                        {
                            loginOK();
                        }
                        else
                        { MessageBox.Show("Kiểm tra lại file xml"); }

                    }
                }
            }
            catch
            { }
        }
Esempio n. 9
0
 /// <summary>
 /// hungvv ====================lay ten server===============
 /// </summary>
 /// <returns></returns>
 public void getServerName(ComboBox combox)
 {
     SqlDataReader read = null;
     SqlConnection conect = new SqlConnection();
     Common.Constants.Sql q = new Common.Constants.Sql();
     try
     {
         conect.ConnectionString = q.ConnectionString;
         conect.Open();
         String sel = null;
         sel = q.selectServerName;
         SqlCommand cmd = new SqlCommand(sel, conect);
         cmd.CommandType = CommandType.Text;
         read = cmd.ExecuteReader();
         while (read.Read())
         {
             combox.Items.Add(read["name"].ToString());
         }
         read.Close();
         conect.Close();
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
 }
Esempio n. 10
0
 public Utilities()
 {
     constants = new Common.Constants.Sql();
 }
Esempio n. 11
0
 /// <summary>
 /// cai dat kho
 /// </summary>
 /// <returns></returns>
 public TruyenGiaTri CaiDatKho(string hanhdong, string ma, string ten)
 {
     Common.Constants.Sql get = new Common.Constants.Sql();
     Entities.TruyenGiaTri giatri = new Entities.TruyenGiaTri();
     string Links = Application.StartupPath.ToString() + get.tenfile;
     try
     {
         XmlDocument doc = new XmlDocument();
         if (CheckFile(Links) == true)
         {
             if (hanhdong == "View")
             {
                 doc.Load(Links);
                 XmlElement root = doc.DocumentElement;
                 giatri.Giatritruyen = GiaiMa(get.setup, root.ChildNodes[0].InnerText);
                 giatri.Giatrithuhai = GiaiMa(get.setup, root.ChildNodes[1].InnerText);
             }
             if (hanhdong == "XuLy")
             {
                 XmlTextWriter txtwrite = new XmlTextWriter(Links, null);
                 txtwrite.WriteStartDocument();
                 txtwrite.WriteStartElement(constants.Connect);
                 txtwrite.WriteElementString("MaKho", MaHoa(get.setup, ma));
                 txtwrite.WriteElementString("TenKho", MaHoa(get.setup, ten));
                 txtwrite.WriteEndElement();
                 txtwrite.WriteEndDocument();
                 txtwrite.Close();
                 giatri.Hanhdong = "Đã lưu lại";
             }
         }
         else
         {
             if (hanhdong == "XuLy")
             {
                 XmlTextWriter txtwrite = new XmlTextWriter(Links, null);
                 txtwrite.WriteStartDocument();
                 txtwrite.WriteStartElement(constants.Connect);
                 txtwrite.WriteElementString("MaKho", MaHoa(get.setup, ma));
                 txtwrite.WriteElementString("TenKho", MaHoa(get.setup, ten));
                 txtwrite.WriteEndElement();
                 txtwrite.WriteEndDocument();
                 txtwrite.Close();
                 giatri.Hanhdong = "Đã lưu lại";
             }
         }
     }
     catch (Exception ex)
     {
         string s = ex.Message.ToString();
         DeleteFile(Links);
         giatri.Hanhdong = "Đã xóa";
     }
     return giatri;
 }