/// <summary>
        /// vuong hung =================================
        /// </summary>
        /// <param name="HanhDong"></param>
        /// <param name="PhieuThuID"></param>
        public int sp_Xoa_ChiTietHoaDonNhap(Entities.ChiTietHoaDonNhap ddh)
        {
            int Trave = 0;

            try
            {
                Sql = new Constants.Sql();
                string sql = Sql.sp_Xoa_ChiTietHoaDonNhap;
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(dh.HanhDong, SqlDbType.NVarChar, 20).Value = ddh.Hanhdong;
                cmd.Parameters.Add(dh.MaHoaDonNhap, SqlDbType.Int).Value      = ddh.MaHoaDonNhap;
                cmd.Parameters.Add(dh.MaHangHoa, SqlDbType.Int).Value         = ddh.MaHangHoa;
                Trave = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(Trave);
        }
        /// <summary>
        /// vuong hung =================xu ly don dat hang================
        /// </summary>
        /// <returns></returns>
        public int sp_XuLy_ChiTietHoaDonNhap(Entities.ChiTietHoaDonNhap ddh)
        {
            int Trave = 0;

            try
            {
                Sql = new Constants.Sql();
                string sql = Sql.sp_XuLy_ChiTietHoaDonNhap;
                conn = new Connection();
                cn   = conn.openConnection();
                dh   = new Constants.ChiTietHoaDonNhap();
                cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(dh.HanhDong, SqlDbType.NVarChar, 20).Value     = ddh.Hanhdong;
                cmd.Parameters.Add(dh.MaHoaDonNhap, SqlDbType.NVarChar, 20).Value = ddh.MaHoaDonNhap;
                cmd.Parameters.Add(dh.MaHangHoa, SqlDbType.NVarChar).Value        = ddh.MaHangHoa;
                cmd.Parameters.Add(dh.SoLuong, SqlDbType.Int).Value = ddh.SoLuong;
                cmd.Parameters.Add(dh.PhanTramChietKhau, SqlDbType.Float, 20).Value = ddh.PhanTramChietKhau;
                cmd.Parameters.Add(dh.DonGia, SqlDbType.Float).Value    = ddh.DonGia;
                cmd.Parameters.Add(dh.Thue, SqlDbType.Float).Value      = ddh.Thue;
                cmd.Parameters.Add(dh.GhiChu, SqlDbType.NVarChar).Value = ddh.GhiChu;
                cmd.Parameters.Add(dh.Deleted, SqlDbType.Bit).Value     = ddh.Deleted;
                Trave = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(Trave);
        }
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ChiTietHoaDonNhap()
 {
     dh         = null;
     Sql        = null;
     conn       = null;
     cmd        = null;
     arr        = null;
     dr         = null;
     hoadonnhap = null;
     cn         = null;
 }
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ChiTietHoaDonNhap()
 {
     dh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     hoadonnhap = null;
     cn = null;
 }
 public Entities.ChiTietHoaDonNhap[] Select()
 {
     Entities.ChiTietHoaDonNhap[] arrC = null;
     try
     {
         dh  = new Constants.ChiTietHoaDonNhap();
         Sql = new Constants.Sql();
         string sql = "Select * from ChiTietHoaDonNhap 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())
         {
             hoadonnhap = new Entities.ChiTietHoaDonNhap();
             hoadonnhap.MaHoaDonNhap      = dr[dh.MaHoaDonNhap].ToString();
             hoadonnhap.MaHangHoa         = dr[dh.MaHangHoa].ToString();
             hoadonnhap.SoLuong           = int.Parse(0 + dr[dh.SoLuong].ToString());
             hoadonnhap.PhanTramChietKhau = Double.Parse(0 + dr[dh.PhanTramChietKhau].ToString()).ToString();
             hoadonnhap.DonGia            = dr[dh.DonGia].ToString();
             hoadonnhap.Thue    = dr[dh.Thue].ToString();
             hoadonnhap.GhiChu  = dr[dh.GhiChu].ToString();
             hoadonnhap.Deleted = Convert.ToBoolean(dr[dh.Deleted].ToString());
             arr.Add(hoadonnhap);
         }
         int n = arr.Count;
         if (n == 0)
         {
             return(null);
         }
         arrC = new Entities.ChiTietHoaDonNhap[n];
         for (int i = 0; i < n; i++)
         {
             arrC[i] = (Entities.ChiTietHoaDonNhap)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return(arrC);
 }
 public void LayChiTietHoaDonNhap()
 {
     ctHDN        = new Entities.ChiTietHoaDonNhap[0];
     cl           = new Server_Client.Client();
     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
     Entities.CheckRefer ctxh = new Entities.CheckRefer("CTHDN", "");
     clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
     Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0];
     ctHDN1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, ctHDN1);
     if (ctHDN1 == null)
     {
         return;
     }
     else
     {
         ctHDN = ctHDN1;
     }
 }
 /// <summary>
 /// vuong hung =================xu ly don dat hang================
 /// </summary>
 /// <returns></returns>
 public int LuuLai(Entities.ChiTietHoaDonNhap[] ddh)
 {
     int Trave = 0;
     Entities.ChiTietHoaDonNhap tl = new Entities.ChiTietHoaDonNhap();
     for (int i = 0; i < ddh.Length; i++)
     {
         tl.Hanhdong = ddh[i].Hanhdong;
         tl.MaHoaDonNhap = ddh[i].MaHoaDonNhap;
         tl.MaHangHoa = ddh[i].MaHangHoa;
         tl.SoLuong = ddh[i].SoLuong;
         tl.PhanTramChietKhau = ddh[i].PhanTramChietKhau;
         tl.DonGia = ddh[i].DonGia;
         tl.Thue = ddh[i].Thue;
         tl.GhiChu = ddh[i].GhiChu;
         tl.Deleted = ddh[i].Deleted;
         Trave = sp_XuLy_ChiTietHoaDonNhap(tl);
     }
     return Trave;
 }
        /// <summary>
        /// vuong hung =================xu ly don dat hang================
        /// </summary>
        /// <returns></returns>
        public int LuuLai(Entities.ChiTietHoaDonNhap[] ddh)
        {
            int Trave = 0;

            Entities.ChiTietHoaDonNhap tl = new Entities.ChiTietHoaDonNhap();
            for (int i = 0; i < ddh.Length; i++)
            {
                tl.Hanhdong          = ddh[i].Hanhdong;
                tl.MaHoaDonNhap      = ddh[i].MaHoaDonNhap;
                tl.MaHangHoa         = ddh[i].MaHangHoa;
                tl.SoLuong           = ddh[i].SoLuong;
                tl.PhanTramChietKhau = ddh[i].PhanTramChietKhau;
                tl.DonGia            = ddh[i].DonGia;
                tl.Thue    = ddh[i].Thue;
                tl.GhiChu  = ddh[i].GhiChu;
                tl.Deleted = ddh[i].Deleted;
                Trave      = sp_XuLy_ChiTietHoaDonNhap(tl);
            }
            return(Trave);
        }
        public DataGridView HienThiChiTiet(string maHDNhap, string maPDCK, string makho)
        {
            cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);

            Entities.ChiTietHoaDonNhap[] kh = new Entities.ChiTietHoaDonNhap[1];
            kh[0] = new Entities.ChiTietHoaDonNhap("Select");
            clientstrem = cl.SerializeObj(this.client1, "ChiTietHoaDonNhap", kh);

            Entities.ChiTietHoaDonNhap[] kh1 = new Entities.ChiTietHoaDonNhap[1];
            kh1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
            if (kh1.Length > 0)
            {
                int ctcount = 0;
                foreach (Entities.ChiTietHoaDonNhap h in kh1)
                {
                    if (h.MaHoaDonNhap == maHDNhap)
                    {
                        ctcount++;
                    }
                }

                Entities.ChiTietHoaDonNhap[] hdn = new Entities.ChiTietHoaDonNhap[ctcount];
                ctcount = 0;
                foreach (Entities.ChiTietHoaDonNhap h in kh1)
                {
                    if (h.MaHoaDonNhap == maHDNhap)
                    {
                        hdn[ctcount] = new Entities.ChiTietHoaDonNhap();
                        hdn[ctcount].MaHangHoa = h.MaHangHoa;
                        hdn[ctcount].SoLuong = h.SoLuong;
                        ctcount++;
                    }
                }

                Server_Client.Client cl1 = new Server_Client.Client();
                this.client1 = cl1.Connect(Luu.IP, Luu.Ports);

                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkh = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                ctkh[0] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
                clientstrem = cl1.SerializeObj(this.client1, "ChiTietKho", ctkh);

                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                ctkh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl1.DeserializeHepper1(clientstrem, kh1);

                Entities.ChiTietPhieuDieuChuyenKho[] ctdck = new Entities.ChiTietPhieuDieuChuyenKho[ctcount];
                for (int i = 0; i < ctdck.Length; i++)
                {
                    ctdck[i] = new Entities.ChiTietPhieuDieuChuyenKho();
                    ctdck[i].MaHangHoa = hdn[i].MaHangHoa;
                    ctdck[i].SoLuong = hdn[i].SoLuong;
                    ctdck[i].MaPhieuDieuChuyenKho = maPDCK;
                    if (ctkh1 != null)
                    {
                        for (int j = 0; j < ctkh1.Length; j++)
                        {
                            if (ctkh1[j].Makho == makho && hdn[i].MaHangHoa == ctkh1[j].Mahanghoa)
                            {
                                ctdck[i].NgayHetHan = ctkh1[i].Ngayhethan;
                            }
                        }
                    }

                }

                dgv.DataSource = ctdck;
                return dgv;
            }
            return dgv;
        }
Esempio n. 10
0
        public DataGridView HienThiChiTiet(string maHDNhap, string maPDCK, string makho)
        {
            cl           = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);

            Entities.ChiTietHoaDonNhap[] kh = new Entities.ChiTietHoaDonNhap[1];
            kh[0]       = new Entities.ChiTietHoaDonNhap("Select");
            clientstrem = cl.SerializeObj(this.client1, "ChiTietHoaDonNhap", kh);

            Entities.ChiTietHoaDonNhap[] kh1 = new Entities.ChiTietHoaDonNhap[1];
            kh1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
            if (kh1.Length > 0)
            {
                int ctcount = 0;
                foreach (Entities.ChiTietHoaDonNhap h in kh1)
                {
                    if (h.MaHoaDonNhap == maHDNhap)
                    {
                        ctcount++;
                    }
                }

                Entities.ChiTietHoaDonNhap[] hdn = new Entities.ChiTietHoaDonNhap[ctcount];
                ctcount = 0;
                foreach (Entities.ChiTietHoaDonNhap h in kh1)
                {
                    if (h.MaHoaDonNhap == maHDNhap)
                    {
                        hdn[ctcount]           = new Entities.ChiTietHoaDonNhap();
                        hdn[ctcount].MaHangHoa = h.MaHangHoa;
                        hdn[ctcount].SoLuong   = h.SoLuong;
                        ctcount++;
                    }
                }

                Server_Client.Client cl1 = new Server_Client.Client();
                this.client1 = cl1.Connect(Luu.IP, Luu.Ports);

                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkh = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                ctkh[0]     = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
                clientstrem = cl1.SerializeObj(this.client1, "ChiTietKho", ctkh);

                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                ctkh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl1.DeserializeHepper1(clientstrem, kh1);



                Entities.ChiTietPhieuDieuChuyenKho[] ctdck = new Entities.ChiTietPhieuDieuChuyenKho[ctcount];
                for (int i = 0; i < ctdck.Length; i++)
                {
                    ctdck[i]                      = new Entities.ChiTietPhieuDieuChuyenKho();
                    ctdck[i].MaHangHoa            = hdn[i].MaHangHoa;
                    ctdck[i].SoLuong              = hdn[i].SoLuong;
                    ctdck[i].MaPhieuDieuChuyenKho = maPDCK;
                    if (ctkh1 != null)
                    {
                        for (int j = 0; j < ctkh1.Length; j++)
                        {
                            if (ctkh1[j].Makho == makho && hdn[i].MaHangHoa == ctkh1[j].Mahanghoa)
                            {
                                ctdck[i].NgayHetHan = ctkh1[i].Ngayhethan;
                            }
                        }
                    }
                }

                dgv.DataSource = ctdck;
                return(dgv);
            }
            return(dgv);
        }
Esempio n. 11
0
 public Entities.ChiTietHoaDonNhap[] Select()
 {
     Entities.ChiTietHoaDonNhap[] arrC = null;
     try
     {
         dh = new Constants.ChiTietHoaDonNhap();
         Sql = new Constants.Sql();
         string sql = "Select * from ChiTietHoaDonNhap 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())
         {
             hoadonnhap = new Entities.ChiTietHoaDonNhap();
             hoadonnhap.MaHoaDonNhap = dr[dh.MaHoaDonNhap].ToString();
             hoadonnhap.MaHangHoa = dr[dh.MaHangHoa].ToString();
             hoadonnhap.SoLuong = int.Parse(0 + dr[dh.SoLuong].ToString());
             hoadonnhap.PhanTramChietKhau = Double.Parse(0 + dr[dh.PhanTramChietKhau].ToString()).ToString();
             hoadonnhap.DonGia = dr[dh.DonGia].ToString();
             hoadonnhap.Thue = dr[dh.Thue].ToString();
             hoadonnhap.GhiChu = dr[dh.GhiChu].ToString();
             hoadonnhap.Deleted = Convert.ToBoolean(dr[dh.Deleted].ToString());
             arr.Add(hoadonnhap);
         }
         int n = arr.Count;
         if (n == 0) { return null; }
         arrC = new Entities.ChiTietHoaDonNhap[n];
         for (int i = 0; i < n; i++)
         {
             arrC[i] = (Entities.ChiTietHoaDonNhap)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return arrC;
 }
Esempio n. 12
0
 public Entities.ChiTietHoaDonNhap[] LuuChiTietHoaDonNhap(DataGridView dgv, string hanhdong, string madondathang)
 {
     ArrayList arr = new ArrayList();
     int i = dgv.RowCount;
     Entities.ChiTietHoaDonNhap[] mangBanghi = null;
     try
     {
         if (i > 0)
         {
             for (int x = 0; x < i; x++)
             {
                 Entities.ChiTietHoaDonNhap banghi = new Entities.ChiTietHoaDonNhap();
                 banghi.Hanhdong = hanhdong;
                 banghi.MaHoaDonNhap = madondathang;
                 banghi.MaHangHoa = dgv.Rows[x].Cells[1].Value.ToString().ToUpper();
                 banghi.SoLuong = System.Convert.ToInt32(dgv.Rows[x].Cells[3].Value.ToString());
                 banghi.PhanTramChietKhau = dgv.Rows[x].Cells[7].Value.ToString();
                 banghi.DonGia = dgv.Rows[x].Cells["GiaGoc"].Value.ToString();
                 banghi.Thue = dgv.Rows[x].Cells["Thuegiatrigiatang"].Value.ToString();
                 banghi.GhiChu = txtDiengiai.Text.ToString();
                 banghi.Deleted = false;
                 banghi.MaKho = new Common.Utilities().CaiDatKho("View", "", "").Giatritruyen;
                 arr.Add(banghi);
             }
             int n = arr.Count;
             if (n == 0) { return null; }
             mangBanghi = new Entities.ChiTietHoaDonNhap[n];
             for (int j = 0; j < n; j++)
             {
                 mangBanghi[j] = (Entities.ChiTietHoaDonNhap)arr[j];
             }
         }
         else
         {
             mangBanghi = null;
         }
     }
     catch (Exception ex)
     { string s = ex.Message; mangBanghi = null; }
     return mangBanghi;
 }
 public void LayChiTietHoaDonNhap()
 {
     ctHDN = new Entities.ChiTietHoaDonNhap[0];
     cl = new Server_Client.Client();
     this.client1 = cl.Connect(Luu.IP, Luu.Ports);
     Entities.CheckRefer ctxh = new Entities.CheckRefer("CTHDN", "");
     clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
     Entities.ChiTietHoaDonNhap[] ctHDN1 = new Entities.ChiTietHoaDonNhap[0];
     ctHDN1 = (Entities.ChiTietHoaDonNhap[])cl.DeserializeHepper1(clientstrem, ctHDN1);
     if (ctHDN1 == null)
     {
         return;
     }
     else
         ctHDN = ctHDN1;
 }