Example #1
0
        //insert update
        public int InsertUpdate(Entities.LoaiHangHoa lhh1)
        {
            try
            {
                lhh = new Constants.LoaiHangHoa();
                Sql = new Constants.Sql();
                string        sql  = Sql.InsertUpdateLoaiHangHoa;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(lhh.HanhDong, SqlDbType.NVarChar, 20).Value     = lhh1.HanhDong;
                cmd.Parameters.Add(lhh.LoaiHangID, SqlDbType.Int).Value            = lhh1.LoaiHangID;
                cmd.Parameters.Add(lhh.MaLoaiHang, SqlDbType.NVarChar, 20).Value   = lhh1.MaLoaiHang;
                cmd.Parameters.Add(lhh.TenLoaiHang, SqlDbType.NVarChar, 200).Value = lhh1.TenLoaiHang;
                cmd.Parameters.Add(lhh.GhiChu, SqlDbType.NVarChar, 250).Value      = lhh1.GhiChu;
                cmd.Parameters.Add(lhh.Deleted, SqlDbType.Bit).Value = lhh1.Deleted;

                int i = cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn   = null;
                conn = null;
                return(i);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Example #2
0
 public LoaiHangHoa()
 {
     lhh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     loaihanghoa = null;
     cn = null;
 }
Example #3
0
 public LoaiHangHoa()
 {
     lhh         = null;
     Sql         = null;
     conn        = null;
     cmd         = null;
     arr         = null;
     dr          = null;
     loaihanghoa = null;
     cn          = null;
 }
Example #4
0
        public Entities.LoaiHangHoa[] Select()
        {
            Entities.LoaiHangHoa[] arrC = null;
            try
            {
                lhh = new Constants.LoaiHangHoa();
                Sql = new Constants.Sql();
                string sql = "Select * from LoaiHang where Deleted = 0";
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr  = new ArrayList();
                while (dr.Read())
                {
                    loaihanghoa             = new Entities.LoaiHangHoa();
                    loaihanghoa.LoaiHangID  = Convert.ToInt32(dr[lhh.LoaiHangID].ToString());
                    loaihanghoa.MaLoaiHang  = dr[lhh.MaLoaiHang].ToString();
                    loaihanghoa.TenLoaiHang = dr[lhh.TenLoaiHang].ToString();
                    loaihanghoa.GhiChu      = dr[lhh.GhiChu].ToString();
                    loaihanghoa.Deleted     = (Boolean)dr[lhh.Deleted];
                    arr.Add(loaihanghoa);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    return(null);
                }
                arrC = new Entities.LoaiHangHoa[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.LoaiHangHoa)arr[i];
                }
            }

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

            return(arrC);
        }
Example #5
0
        //delete
        public void Delete(Entities.LoaiHangHoa lhh1)
        {
            lhh = new Constants.LoaiHangHoa();
                Entities.LoaiHangHoa loaihanghoa = new Entities.LoaiHangHoa();
                Sql = new Constants.Sql();
                string sql = Sql.DeleteLoaiHangHoa;
                Connection conn = new Connection();
                SqlConnection cn = conn.openConnection();
                SqlCommand cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(lhh.HanhDong, SqlDbType.NVarChar, 20).Value = lhh1.HanhDong;
                cmd.Parameters.Add(lhh.LoaiHangID, SqlDbType.Int).Value = lhh1.LoaiHangID;

                cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn = null;
                conn = null;
        }
Example #6
0
        //delete
        public void Delete(Entities.LoaiHangHoa lhh1)
        {
            lhh = new Constants.LoaiHangHoa();
            Entities.LoaiHangHoa loaihanghoa = new Entities.LoaiHangHoa();
            Sql = new Constants.Sql();
            string        sql  = Sql.DeleteLoaiHangHoa;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);

            cmd.Parameters.Add(lhh.HanhDong, SqlDbType.NVarChar, 20).Value = lhh1.HanhDong;
            cmd.Parameters.Add(lhh.LoaiHangID, SqlDbType.Int).Value        = lhh1.LoaiHangID;

            cmd.ExecuteNonQuery();
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
        }
Example #7
0
        //Entities
        public Entities.LoaiHangHoa[] sp_SelectLoaiHangHoasAll()
        {
            Entities.LoaiHangHoa[] arrC = null;
            try
            {
                lhh = new Constants.LoaiHangHoa();
                Sql = new Constants.Sql();
                string sql = Sql.SelectAllLoaiHangHoa;
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    loaihanghoa = new Entities.LoaiHangHoa();
                    loaihanghoa.LoaiHangID = Convert.ToInt32(dr[lhh.LoaiHangID].ToString());
                    loaihanghoa.MaLoaiHang = dr[lhh.MaLoaiHang].ToString();
                    loaihanghoa.TenLoaiHang = dr[lhh.TenLoaiHang].ToString();
                    loaihanghoa.GhiChu = dr[lhh.GhiChu].ToString();
                    loaihanghoa.Deleted = (Boolean)dr[lhh.Deleted];
                    arr.Add(loaihanghoa);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new Entities.LoaiHangHoa[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.LoaiHangHoa)arr[i];
                }
            }

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

            return arrC;
        }
Example #8
0
 private void btnThemNhomHang_Click(object sender, EventArgs e)
 {
     try
     {
         frmXuLyNhomHangHoa tnhh = new frmXuLyNhomHangHoa("Insert");
         tnhh.ShowDialog();
         Entities.LoaiHangHoa lhh = new Entities.LoaiHangHoa();
         lhh = (Entities.LoaiHangHoa)cbbLoaiHangHoa.SelectedValue;
         string maLoai = lhh.MaLoaiHang;
         LayMaNhomHangHoa(maLoai);
     }
     catch { }
 }
Example #9
0
        //Lấy Mã Nhóm Hàng Hóa
        public void LayLoaiHangHoa()
        {
            try
            {
                cbbLoaiHangHoa.DataSource = null;
                client = new Server_Client.Client();
                this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

                Entities.LoaiHangHoa nh = new Entities.LoaiHangHoa();
                nh = new Entities.LoaiHangHoa("Select");
                networkStream = client.SerializeObj(this.tcpClient, "LoaiHangHoa", nh);
                Entities.LoaiHangHoa[] nh1 = new Entities.LoaiHangHoa[1];
                nh1 = (Entities.LoaiHangHoa[])client.DeserializeHepper1(networkStream, nh1);

                cbbLoaiHangHoa.DataSource = nh1;
                cbbLoaiHangHoa.DisplayMember = "TenLoaiHang";
            }
            catch (Exception) { }
        }