Beispiel #1
0
        public int InsertUpdate(Entities.GoiHang nhom)
        {
            int rt = 0;

            try
            {
                conn = new Connection();
                SqlConnection cn  = conn.openConnection();
                SqlCommand    cmd = new SqlCommand(Common.Constants.Sql.GoiHang.InsertUpdateGoiHang, cn);
                cmd.Parameters.Add(Common.Constants.GoiHang.HanhDong, SqlDbType.NVarChar).Value         = nhom.HanhDong;
                cmd.Parameters.Add(Common.Constants.GoiHang.GoiHangID, SqlDbType.Int).Value             = nhom.GoiHangID;
                cmd.Parameters.Add(Common.Constants.GoiHang.MaKho, SqlDbType.VarChar, 20).Value         = nhom.MaKho.ToUpper();
                cmd.Parameters.Add(Common.Constants.GoiHang.MaGoiHang, SqlDbType.VarChar, 50).Value     = nhom.MaGoiHang.ToUpper();
                cmd.Parameters.Add(Common.Constants.GoiHang.TenGoiHang, SqlDbType.NVarChar, 200).Value  = nhom.TenGoiHang;
                cmd.Parameters.Add(Common.Constants.GoiHang.MaNhomHang, SqlDbType.VarChar, 50).Value    = nhom.MaNhomHang;
                cmd.Parameters.Add(Common.Constants.GoiHang.TenNhomHang, SqlDbType.NVarChar, 200).Value = nhom.TenNhomHang;
                cmd.Parameters.Add(Common.Constants.GoiHang.GiaNhap, SqlDbType.Float).Value             = nhom.GiaNhap;
                cmd.Parameters.Add(Common.Constants.GoiHang.GiaBanBuon, SqlDbType.Float).Value          = nhom.GiaBanBuon;
                cmd.Parameters.Add(Common.Constants.GoiHang.GiaBanLe, SqlDbType.Float).Value            = nhom.GiaBanLe;
                cmd.Parameters.Add(Common.Constants.GoiHang.Deleted, SqlDbType.Bit).Value = nhom.Deleted;
                rt = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); rt = 0; }
            return(rt);
        }
Beispiel #2
0
 public GoiHang()
 {
     kh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     goihang = null;
     cn = null;
 }
Beispiel #3
0
 public GoiHang()
 {
     kh      = null;
     Sql     = null;
     conn    = null;
     cmd     = null;
     arr     = null;
     dr      = null;
     goihang = null;
     cn      = null;
 }
Beispiel #4
0
        public int Delete(Entities.GoiHang nhom)
        {
            int rt = 0;

            try
            {
                conn = new Connection();
                SqlConnection cn  = conn.openConnection();
                SqlCommand    cmd = new SqlCommand(Common.Constants.Sql.GoiHang.DeleteGoiHang, cn);
                cmd.Parameters.Add(Common.Constants.GoiHang.GoiHangID, SqlDbType.Int).Value = nhom.GoiHangID;
                rt = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); rt = 0; }
            return(rt);
        }
Beispiel #5
0
 public Entities.GoiHang[] Select()
 {
     Entities.GoiHang[] list = null;
     try
     {
         string sql = Common.Constants.Sql.GoiHang.SelectGoiHang;
         conn = new Connection();
         cn   = conn.openConnection();
         cmd  = new SqlCommand(sql, cn);
         dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr  = new ArrayList();
         while (dr.Read())
         {
             Entities.GoiHang row = new Entities.GoiHang();
             row.GoiHangID   = Convert.ToInt32(dr[Common.Constants.GoiHang.GoiHangID].ToString());
             row.MaKho       = dr[Common.Constants.GoiHang.MaKho].ToString();
             row.MaGoiHang   = dr[Common.Constants.GoiHang.MaGoiHang].ToString();
             row.TenGoiHang  = dr[Common.Constants.GoiHang.TenGoiHang].ToString();
             row.MaNhomHang  = dr[Common.Constants.GoiHang.MaNhomHang].ToString();
             row.TenNhomHang = dr[Common.Constants.GoiHang.TenNhomHang].ToString();
             row.GiaNhap     = dr[Common.Constants.GoiHang.GiaNhap].ToString();
             row.GiaBanBuon  = dr[Common.Constants.GoiHang.GiaBanBuon].ToString();
             row.GiaBanLe    = dr[Common.Constants.GoiHang.GiaBanLe].ToString();
             row.Deleted     = Boolean.Parse(dr[Common.Constants.GoiHang.Deleted].ToString());
             arr.Add(row);
         }
         int n = arr.Count;
         if (n == 0)
         {
             list = null;
         }
         list = new Entities.GoiHang[n];
         for (int i = 0; i < n; i++)
         {
             list[i] = (Entities.GoiHang)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); list = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return(list);
 }
Beispiel #6
0
 public Entities.GoiHang[] Select(Entities.GoiHang hh)
 {
     Entities.GoiHang[] list = null;
     try
     {
         conn = new Connection();
         cn   = conn.openConnection();
         cmd  = new SqlCommand(Common.Constants.Sql.GoiHang.SelectTheoMaGoiHang, cn);
         cmd.Parameters.Add(Common.Constants.GoiHang.MaGoiHang, SqlDbType.VarChar, 50).Value = hh.MaGoiHang;
         dr  = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.GoiHang row = new Entities.GoiHang();
             row.GoiHangID   = int.Parse(dr[Common.Constants.GoiHang.GoiHangID].ToString());
             row.MaKho       = dr[Common.Constants.GoiHang.MaKho].ToString();
             row.MaGoiHang   = dr[Common.Constants.GoiHang.MaGoiHang].ToString();
             row.TenGoiHang  = dr[Common.Constants.GoiHang.TenGoiHang].ToString();
             row.MaNhomHang  = dr[Common.Constants.GoiHang.MaNhomHang].ToString();
             row.TenNhomHang = dr[Common.Constants.GoiHang.TenNhomHang].ToString();
             row.GiaBanBuon  = dr[Common.Constants.GoiHang.GiaBanBuon].ToString();
             row.GiaBanLe    = dr[Common.Constants.GoiHang.GiaBanLe].ToString();
             arr.Add(row);
         }
         if (arr.Count > 0)
         {
             list = (Entities.GoiHang[])arr.ToArray(typeof(Entities.GoiHang));
         }
         else
         {
             list = new Entities.GoiHang[0];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); list = new Entities.GoiHang[0]; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return(list);
 }
Beispiel #7
0
        /// <summary>
        /// GetGVGoiHang
        /// </summary>
        /// <param name="maHd"> </param>
        /// <param name="maGoi"></param>
        /// <param name="gh"></param>
        /// <returns></returns>
        public GiaVonBanHang GetGvGoiHang(string maHd, string maGoi, GoiHang[] gh)
        {
            GiaVonBanHang retVal = null;
            try
            {
                foreach (GoiHang item in gh.Where(item => item.MaGoiHang.Trim().ToUpper().Equals(maGoi.Trim().ToUpper())))
                {
                    retVal = new GiaVonBanHang
                                 {
                                     HanhDong = "Insert",
                                     MaHangHoa = maGoi.Trim().ToUpper(),
                                     MaHoaDon = maHd.Trim().ToUpper(),
                                     GiaVon = double.Parse(item.GiaNhap)
                                 };
                    break;
                }
            }
            catch
            {
                retVal = null;
            }

            return retVal;
        }
        /// <summary>
        /// Lấy dữ liệu bảng hàng hóa và gói hàng (Chạy 1 lần để lấy dữ liệu và gán vào biến dùng chung)
        /// </summary>
        /// <returns></returns>
        List<ThongTinMaVach> GetHangHoaGoiHang()
        {
            List<ThongTinMaVach> dsThongTinMaVachs = new List<ThongTinMaVach>();
            try
            {
                //Lấy MaHangHoa,TenHangHoa,GiaNhap,GiaBanBuon,GiaBanLe,GhiChu từ bảng HÀNG HÓA
                cl = new Server_Client.Client();
                client = cl.Connect(Luu.IP, Luu.Ports);
                ThongTinMaVach row1 = new ThongTinMaVach("Select");
                clientstrem = cl.SerializeObj(client, "ThongTinMaVachHangHoa", row1);
                ThongTinMaVach[] dsHangHoa = new ThongTinMaVach[0];
                dsHangHoa = (ThongTinMaVach[])cl.DeserializeHepper(clientstrem, dsHangHoa);
                client.Close();
                clientstrem.Close();
                if (dsHangHoa != null)
                    dsThongTinMaVachs.AddRange(dsHangHoa);
            }
            catch { }

            try
            {
                //Lấy a.GoiHangID,a.MaKho,a.MaGoiHang,a.TenGoiHang,a.MaNhomHang,b.TenNhomHang,a.GiaNhap,a.GiaBanBuon,a.GiaBanLe,a.Deleted
                //FROM GoiHang a join NhomHang b on a.MaNhomHang=b.MaNhomHang  WHERE a.Deleted='False'
                cl = new Server_Client.Client();
                client = cl.Connect(Luu.IP, Luu.Ports);
                GoiHang goi = new GoiHang("Select");
                clientstrem = cl.SerializeObj(client, "GoiHang", goi);
                GoiHang[] goiHang = new GoiHang[0];
                goiHang = (GoiHang[])cl.DeserializeHepper1(clientstrem, goiHang);
                if (goiHang != null)
                {
                    foreach (GoiHang item in goiHang)
                    {
                        if (item.Deleted) continue;
                        ThongTinMaVach row = new ThongTinMaVach
                                                 {
                                                     MaHangHoa = item.MaGoiHang,
                                                     TenHangHoa = item.TenGoiHang,
                                                     GiaNhap = item.GiaNhap,
                                                     GiaBanBuon = item.GiaBanBuon,
                                                     GiaBanLe = item.GiaBanLe
                                                 };
                        dsThongTinMaVachs.Add(row);
                    }
                }
            }
            catch { }

            return dsThongTinMaVachs;
        }
Beispiel #9
0
 public Entities.GoiHang[] Select()
 {
     Entities.GoiHang[] list = null;
     try
     {
         string sql = Common.Constants.Sql.GoiHang.SelectGoiHang;
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(sql, cn);
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.GoiHang row = new Entities.GoiHang();
             row.GoiHangID = Convert.ToInt32(dr[Common.Constants.GoiHang.GoiHangID].ToString());
             row.MaKho = dr[Common.Constants.GoiHang.MaKho].ToString();
             row.MaGoiHang = dr[Common.Constants.GoiHang.MaGoiHang].ToString();
             row.TenGoiHang = dr[Common.Constants.GoiHang.TenGoiHang].ToString();
             row.MaNhomHang = dr[Common.Constants.GoiHang.MaNhomHang].ToString();
             row.TenNhomHang = dr[Common.Constants.GoiHang.TenNhomHang].ToString();
             row.GiaNhap = dr[Common.Constants.GoiHang.GiaNhap].ToString();
             row.GiaBanBuon = dr[Common.Constants.GoiHang.GiaBanBuon].ToString();
             row.GiaBanLe = dr[Common.Constants.GoiHang.GiaBanLe].ToString();
             row.Deleted = Boolean.Parse(dr[Common.Constants.GoiHang.Deleted].ToString());
             arr.Add(row);
         }
         int n = arr.Count;
         if (n == 0) { list = null; }
         list = new Entities.GoiHang[n];
         for (int i = 0; i < n; i++)
         {
             list[i] = (Entities.GoiHang)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); list = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return list;
 }
Beispiel #10
0
 public Entities.GoiHang[] Select(Entities.GoiHang hh)
 {
     Entities.GoiHang[] list = null;
     try
     {
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(Common.Constants.Sql.GoiHang.SelectTheoMaGoiHang, cn);
         cmd.Parameters.Add(Common.Constants.GoiHang.MaGoiHang, SqlDbType.VarChar, 50).Value = hh.MaGoiHang;
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.GoiHang row = new Entities.GoiHang();
             row.GoiHangID = int.Parse(dr[Common.Constants.GoiHang.GoiHangID].ToString());
             row.MaKho = dr[Common.Constants.GoiHang.MaKho].ToString();
             row.MaGoiHang = dr[Common.Constants.GoiHang.MaGoiHang].ToString();
             row.TenGoiHang = dr[Common.Constants.GoiHang.TenGoiHang].ToString();
             row.MaNhomHang = dr[Common.Constants.GoiHang.MaNhomHang].ToString();
             row.TenNhomHang = dr[Common.Constants.GoiHang.TenNhomHang].ToString();
             row.GiaBanBuon = dr[Common.Constants.GoiHang.GiaBanBuon].ToString();
             row.GiaBanLe = dr[Common.Constants.GoiHang.GiaBanLe].ToString();
             arr.Add(row);
         }
         if (arr.Count > 0)
         {
             list = (Entities.GoiHang[])arr.ToArray(typeof(Entities.GoiHang));
         }
         else
         {
             list = new Entities.GoiHang[0];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); list = new Entities.GoiHang[0]; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return list;
 }