Ejemplo n.º 1
0
        public int sp_XuLy_ChiTietHoaDonNhapKho(Entities.ChiTietKhoHangTheoHoaHonNhap dh)
        {
            int Trave = 0;

            try
            {
                string sql = "exec sp_XuLy_ChiTietHoaDonNhapKhoHangFIX @HanhDong,@MaKho,@MaHangHoa,@SoLuong,@NgayNhap,	@HanSuDung,@GhiChu,@Deleted,@Gia";
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add("HanhDong", SqlDbType.VarChar, 20).Value = dh.Hanhdong;
                cmd.Parameters.Add("MaKho", SqlDbType.VarChar, 20).Value    = dh.Makho;
                cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar).Value    = dh.Mahanghoa;
                cmd.Parameters.Add("SoLuong", SqlDbType.Int).Value          = dh.Soluong;
                cmd.Parameters.Add("NgayNhap", SqlDbType.DateTime).Value    = dh.Ngaynhap;
                cmd.Parameters.Add("HanSuDung", SqlDbType.DateTime).Value   = dh.Ngayhethan;
                cmd.Parameters.Add("GhiChu", SqlDbType.NVarChar).Value      = dh.Ghichu;
                cmd.Parameters.Add("Deleted", SqlDbType.Bit).Value          = dh.Deleted;
                cmd.Parameters.Add("Gia", SqlDbType.Float).Value            = dh.Gia;
                Trave = cmd.ExecuteNonQuery();
            }
            catch { Trave = 0; }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(Trave);
        }
Ejemplo n.º 2
0
        public int CongSoLuong(Entities.ChiTietKhoHangTheoHoaHonNhap dh)
        {
            int Trave = 0;

            try
            {
                string sql = "exec sp_CongSoLuong_CHITIETKHOHANG_k29 @MaKho,@MaHangHoa,@SoLuong";
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add("MaKho", SqlDbType.VarChar, 20).Value     = dh.Makho;
                cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar, 50).Value = dh.Mahanghoa;
                cmd.Parameters.Add("SoLuong", SqlDbType.Int).Value           = dh.Soluong;
                Trave = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(Trave);
        }
Ejemplo n.º 3
0
        public void CheckDataGridCongSL1(DataGridView dgv, string maKho)
        {
            Server_Client.Client cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
            Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
            clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
            Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
            kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
            List <Entities.ChiTietKhoHangTheoHoaHonNhap> ctKhoList = new List <Entities.ChiTietKhoHangTheoHoaHonNhap>();

            try
            {
                if (dgv.RowCount != 0)
                {
                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1)
                        {
                            // lay cac hang hoa da ton tai
                            if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()))
                            {
                                Entities.ChiTietKhoHangTheoHoaHonNhap ct;
                                ct = new Entities.ChiTietKhoHangTheoHoaHonNhap("UpdateCong", maKho, dgv["MaHangHoa", i].Value.ToString(), int.Parse(dgv["SoLuong", i].Value.ToString()));
                                ctKhoList.Add(ct);
                                break;
                            }
                        }
                    }
                    TruSLMang(ctKhoList.ToArray());
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ChiTietKhoHangTheoHoaHonNhap()
 {
     Sql        = null;
     conn       = null;
     cmd        = null;
     arr        = null;
     dr         = null;
     hoadonnhap = null;
     cn         = null;
 }
 /// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ChiTietKhoHangTheoHoaHonNhap()
 {
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     hoadonnhap = null;
     cn = null;
 }
Ejemplo n.º 6
0
 public void CheckDataGridTruSL(DataGridView dgv, string maKho)
 {
     if (dgv.RowCount != 0)
     {
         Entities.ChiTietKhoHangTheoHoaHonNhap[] cthdbh = new Entities.ChiTietKhoHangTheoHoaHonNhap[dgv.RowCount];
         for (int j = 0; j < cthdbh.Length; j++)
         {
             cthdbh[j] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, dgv["MaHangHoa", j].Value.ToString(), int.Parse(dgv["SoLuong", j].Value.ToString()));
         }
         TruSLMang(cthdbh);
     }
 }
        public void CheckDataGridCongSL(DataGridView dgv, string maKho)
        {
            if (dgv.RowCount != 0)
            {
                try
                {

                    Server_Client.Client cl = new Server_Client.Client();
                    this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                    Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
                    clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
                    Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
                    kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
                    List<Entities.ChiTietKhoHangTheoHoaHonNhap> ctList = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>();
                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        bool retVal = false;
                        foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1)
                        {
                            if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()) && maKho.Equals(item.Makho))
                            {
                                retVal = true;
                                break;
                            }
                        }
                        if (!retVal)
                        {
                            Entities.ChiTietKhoHangTheoHoaHonNhap ct = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                            ct.Hanhdong = "Insert";
                            ct.Mahanghoa = dgv["MaHangHoa", i].Value.ToString();
                            ct.Makho = maKho;
                            ct.Ngaynhap = DateServer.Date();
                            DateTime ngayHetHan = DateTime.Now;
                            if (dgv["NgayHetHan", i] != null)
                                ngayHetHan = (DateTime)dgv["NgayHetHan", i].Value;
                            ct.Ngayhethan = ngayHetHan;
                            ct.Soluong = int.Parse(dgv["SoLuong", i].Value.ToString());
                            ct.Ghichu = "";
                            ctList.Add(ct);
                        }
                    }
                    Server_Client.Client cl1 = new Server_Client.Client();
                    this.client1 = cl1.Connect(Luu.IP, Luu.Ports);
                    clientstrem = cl1.SerializeObj(this.client1, "ThemChiTietKhoHang", ctList.ToArray());
                }
                catch (Exception)
                {

                }
            }
        }
Ejemplo n.º 8
0
 public void CheckDataGridCongSL(DataGridView dgv, string maKho)
 {
     if (dgv.RowCount != 0)
     {
         try
         {
             Server_Client.Client cl = new Server_Client.Client();
             this.client1 = cl.Connect(Luu.IP, Luu.Ports);
             Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
             clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
             Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
             kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
             List <Entities.ChiTietKhoHangTheoHoaHonNhap> ctList = new List <Entities.ChiTietKhoHangTheoHoaHonNhap>();
             for (int i = 0; i < dgv.RowCount; i++)
             {
                 bool retVal = false;
                 foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1)
                 {
                     if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()) && maKho.Equals(item.Makho))
                     {
                         retVal = true;
                         break;
                     }
                 }
                 if (!retVal)
                 {
                     Entities.ChiTietKhoHangTheoHoaHonNhap ct = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                     ct.Hanhdong  = "Insert";
                     ct.Mahanghoa = dgv["MaHangHoa", i].Value.ToString();
                     ct.Makho     = maKho;
                     ct.Ngaynhap  = DateServer.Date();
                     DateTime ngayHetHan = DateTime.Now;
                     if (dgv["NgayHetHan", i] != null)
                     {
                         ngayHetHan = (DateTime)dgv["NgayHetHan", i].Value;
                     }
                     ct.Ngayhethan = ngayHetHan;
                     ct.Soluong    = int.Parse(dgv["SoLuong", i].Value.ToString());
                     ct.Ghichu     = "";
                     ctList.Add(ct);
                 }
             }
             Server_Client.Client cl1 = new Server_Client.Client();
             this.client1 = cl1.Connect(Luu.IP, Luu.Ports);
             clientstrem  = cl1.SerializeObj(this.client1, "ThemChiTietKhoHang", ctList.ToArray());
         }
         catch (Exception)
         {
         }
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// vuong hung =================xu ly don dat hang================
        /// </summary>
        /// <returns></returns>
        ///

        public Entities.ChiTietKhoHangTheoHoaHonNhap[] Select()
        {
            Entities.ChiTietKhoHangTheoHoaHonNhap[] arrC = null;
            try
            {
                Sql = new Constants.Sql();
                string sql = Sql.SelectAllChiTietKhoHang;
                conn = new Connection();
                cn   = conn.openConnection();
                cmd  = new SqlCommand(sql, cn);
                dr   = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr  = new ArrayList();
                while (dr.Read())
                {
                    Entities.ChiTietKhoHangTheoHoaHonNhap ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                    ctkho.Makho      = dr["MaKho"].ToString();
                    ctkho.Mahanghoa  = dr["MaHangHoa"].ToString();
                    ctkho.Soluong    = Convert.ToInt32(dr["SoLuong"].ToString());
                    ctkho.Ngaynhap   = DateTime.Parse(dr["NgayNhap"].ToString());
                    ctkho.Ngayhethan = DateTime.Parse(dr["HanSuDung"].ToString());
                    ctkho.Ghichu     = dr["GhiChu"].ToString();
                    arr.Add(ctkho);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    return(null);
                }
                arrC = new Entities.ChiTietKhoHangTheoHoaHonNhap[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.ChiTietKhoHangTheoHoaHonNhap)arr[i];
                }
            }

            catch (Exception ex)
            {
                string s = ex.Message.ToString();
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(arrC);
        }
Ejemplo n.º 10
0
        public void LayChiTiet_HangHoaXuat_TheoKho(string maKho, string tenKho)
        {
            try
            {
                int count = 0;
                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    if (ctHangHoaTheoKho[i].Makho == maKho)
                    {
                        count++;
                    }
                }
                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[count];
                count = 0;

                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    if (ctHangHoaTheoKho[i].Makho == maKho)
                    {
                        ctkho[count] = ctHangHoaTheoKho[i];
                        count++;
                    }
                }

                ctBCXH = new Entities.CTBCNhapHangTheoKho[count];
                for (int i = 0; i < ctkho.Length; i++)
                {
                    ctBCXH[i]                 = new Entities.CTBCNhapHangTheoKho();
                    ctBCXH[i].MaKho           = ctkho[i].Makho;
                    ctBCXH[i].TenKho          = tenKho;
                    ctBCXH[i].MaHangHoa       = ctkho[i].Mahanghoa;
                    ctBCXH[i].TongSoLuongNhap = 0;
                    for (int j = 0; j < HangHoa.Length; j++)
                    {
                        if (HangHoa[j].MaHangHoa == ctBCXH[i].MaHangHoa)
                        {
                            ctBCXH[i].TenHangHoa = HangHoa[j].TenHangHoa;
                            break;
                        }
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 11
0
 public void LayChiTiet_HangHoaXuat()
 {
     try
     {
         cl           = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
         clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
         Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
         kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
         if (kh1 == null)
         {
             ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
             return;
         }
         ctHangHoaTheoKho = kh1;
     }
     catch { }
 }
Ejemplo n.º 12
0
 public int CongSoLuong(Entities.ChiTietKhoHangTheoHoaHonNhap[] dh)
 {
     try
     {
         for (int i = 0; i < dh.Length; i++)
         {
             if (dh[i].Mahanghoa != "")
             {
                 int tem0          = KiemTraLaySoLuongTrongKho(dh[i].Makho, dh[i].Mahanghoa);
                 int soluongupdate = dh[i].Soluong;
                 Entities.ChiTietKhoHangTheoHoaHonNhap dh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap(" ", dh[i].Makho, dh[i].Mahanghoa, soluongupdate);
                 CongSoLuong(dh1);
             }
         }
     }
     catch
     {
         return(0);
     }
     return(1);
 }
Ejemplo n.º 13
0
        public int LuuLai(Entities.ChiTietKhoHangTheoHoaHonNhap[] ddh)
        {
            int        tra   = 0;
            List <int> error = new List <int>();

            try
            {
                for (int i = 0; i < ddh.Length; i++)
                {
                    Entities.ChiTietKhoHangTheoHoaHonNhap tl = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                    tl.Hanhdong   = ddh[i].Hanhdong;
                    tl.Makho      = ddh[i].Makho;
                    tl.Mahanghoa  = ddh[i].Mahanghoa;
                    tl.Soluong    = ddh[i].Soluong;
                    tl.Ngaynhap   = ddh[i].Ngaynhap;
                    tl.Ngayhethan = ddh[i].Ngayhethan;
                    tl.Ghichu     = ddh[i].Ghichu;
                    tl.Deleted    = ddh[i].Deleted;
                    tl.Gia        = ddh[i].Gia;
                    int _return = sp_XuLy_ChiTietHoaDonNhapKho(tl);
                    if (_return == 0)
                    {
                        error.Add(i);
                    }
                }
                if (error.Count == 0)
                {
                    tra = 1;    //Không có lỗi gì
                }
                else
                {
                    if (error.Count < ddh.Length)
                    {
                        tra = -1;   //Có một số lỗi
                    }
                }
            }
            catch { tra = 0; }
            return(tra);
        }
Ejemplo n.º 14
0
 private void LuuChiTietDonHang()
 {
     try
     {
         if (XoaTheoHoaDon("HoaDonNhap", txtSodonhang.Text.ToUpper()) != 0)
         {
             cl = new Server_Client.Client();
             this.client = cl.Connect(Luu.IP, Luu.Ports);
             Entities.ChiTietHoaDonNhap[] luu = LuuChiTietHoaDonNhap(dgvInsertOrder, "Insert", txtSodonhang.Text);
             clientstrem = cl.SerializeHepper(this.client, "ChiTietHoaDonNhap", luu);
             int bao = 0;
             bao = (int)cl.DeserializeHepper(clientstrem, bao);
             if (bao != 0)
             {
                 int k = dgvInsertOrder.RowCount;
                 Entities.ChiTietKhoHangTheoHoaHonNhap[] khohang = new Entities.ChiTietKhoHangTheoHoaHonNhap[k];
                 ArrayList arr = new ArrayList();
                 if (k > 0)
                 {
                     for (int x = 0; x < k; x++)
                     {
                         Entities.ChiTietKhoHangTheoHoaHonNhap kho = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                         kho.Hanhdong = "Insert";
                         kho.Makho = cbxKhoHang.SelectedValue.ToString();
                         kho.Mahanghoa = dgvInsertOrder.Rows[x].Cells[1].Value.ToString();
                         kho.Soluong = int.Parse(dgvInsertOrder.Rows[x].Cells[3].Value.ToString());
                         kho.Ngaynhap = Date.Date;
                         //string ngay = new Common.Utilities().KiemTraDinhDangNgayThangNam("ThangNgayNam", dgvInsertOrder.Rows[x].Cells[12].Value.ToString(), '/');
                         //kho.Ngayhethan = DateTime.Parse(ngay);
                         kho.Ngayhethan = Utils.StringToDateTime(dgvInsertOrder.Rows[x].Cells[12].Value.ToString());
                         kho.Ghichu = txtDiengiai.Text;
                         kho.Deleted = false;
                         kho.Gia = float.Parse(dgvInsertOrder.Rows[x].Cells[4].Value.ToString());
                         arr.Add(kho);
                     }
                     int n = arr.Count;
                     if (n == 0)
                     { khohang = null; }
                     khohang = new Entities.ChiTietKhoHangTheoHoaHonNhap[n];
                     for (int j = 0; j < n; j++)
                     { khohang[j] = (Entities.ChiTietKhoHangTheoHoaHonNhap)arr[j]; }
                 }
                 else
                 { khohang = null; }
                 LuuChiTietVaoKhoHang(khohang);
             }
             else
             { DeleteData(txtSodonhang.Text); MessageBox.Show("Thất bại"); }
         }
         else
         { MessageBox.Show("Chưa thêm hàng hóa vào đơn nhập hàng này"); }
     }
     catch (Exception ex)
     { string s = ex.Message; }
 }
Ejemplo n.º 15
0
 public void LayChiTiet_HangHoaXuat()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
         clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
         Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
         kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
         if (kh1 == null)
         {
             ctHangHoaTheoKho = new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
             return;
         }
         ctHangHoaTheoKho = kh1;
     }
     catch { }
 }
        public void CheckDataGridCongSL1(DataGridView dgv, string maKho)
        {
            Server_Client.Client cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
            Entities.ChiTietKhoHangTheoHoaHonNhap nv = new Entities.ChiTietKhoHangTheoHoaHonNhap("Select");
            clientstrem = cl.SerializeObj(this.client1, "ChiTietKho", nv);
            Entities.ChiTietKhoHangTheoHoaHonNhap[] kh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap[1];
            kh1 = (Entities.ChiTietKhoHangTheoHoaHonNhap[])cl.DeserializeHepper1(clientstrem, kh1);
            List<Entities.ChiTietKhoHangTheoHoaHonNhap> ctKhoList = new List<Entities.ChiTietKhoHangTheoHoaHonNhap>();
            try
            {
                if (dgv.RowCount != 0)
                {

                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        foreach (Entities.ChiTietKhoHangTheoHoaHonNhap item in kh1)
                        {
                            // lay cac hang hoa da ton tai
                            if (dgv["MaHangHoa", i].Value.ToString().ToUpper().Equals(item.Mahanghoa.ToUpper()))
                            {
                                Entities.ChiTietKhoHangTheoHoaHonNhap ct;
                                ct = new Entities.ChiTietKhoHangTheoHoaHonNhap("UpdateCong", maKho, dgv["MaHangHoa", i].Value.ToString(), int.Parse(dgv["SoLuong", i].Value.ToString()));
                                ctKhoList.Add(ct);
                                break;
                            }
                        }
                    }
                    TruSLMang(ctKhoList.ToArray());

                }
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// kiểm tra dtgv trước khi trừ số lượng
 /// </summary>
 /// <param name="dgv"></param>
 public Entities.ChiTietKhoHangTheoHoaHonNhap[] CheckDataGridTruSL(DataGridView dgv)
 {
     ArrayList array = new ArrayList();
     bool kkt = false;
     try
     {
         if (dgv.RowCount != 0)
         {
             Entities.ChiTietKhoHangTheoHoaHonNhap[] cthdbh = new Entities.ChiTietKhoHangTheoHoaHonNhap[dgv.RowCount];
             Entities.ChiTietKhoHangTheoHoaHonNhap temp = new Entities.ChiTietKhoHangTheoHoaHonNhap();
             for (int j = 0; j < dgv.RowCount; j++)
             {
                 bool kt = false;
                 string maKho = LayMaKho(cbbkhohang.Text);
                 foreach (Entities.GoiHang item1 in _goihang)
                 {
                     if (dgv[1, j].Value.ToString() == item1.MaGoiHang.ToUpper())
                     {
                         foreach (Entities.ChiTietGoiHang item2 in _chitietgoihang)
                         {
                             if (item1.MaGoiHang.ToUpper() == item2.MaGoiHang.ToUpper())
                             {
                                 temp = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, item2.MaHangHoa, int.Parse(dgv["SoLuong", j].Value.ToString()) * item2.SoLuong);
                                 array.Add(temp);
                                 kt = true;
                             }
                         }
                         break;
                     }
                 }
                 if (!kt)
                 {
                     temp = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, dgv[1, j].Value.ToString(), int.Parse(dgv["SoLuong", j].Value.ToString()));
                     array.Add(temp);
                 }
             }
             cthdbh = (Entities.ChiTietKhoHangTheoHoaHonNhap[])array.ToArray(typeof(Entities.ChiTietKhoHangTheoHoaHonNhap));
             return cthdbh;
         }
         return new Entities.ChiTietKhoHangTheoHoaHonNhap[0];
     }
     catch
     {
         return new Entities.ChiTietKhoHangTheoHoaHonNhap[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;
        }
 public int CongSoLuong(Entities.ChiTietKhoHangTheoHoaHonNhap[] dh)
 {
     try
     {
         for (int i = 0; i < dh.Length; i++)
         {
             if (dh[i].Mahanghoa != "")
             {
                 int tem0 = KiemTraLaySoLuongTrongKho(dh[i].Makho, dh[i].Mahanghoa);
                 int soluongupdate = dh[i].Soluong;
                 Entities.ChiTietKhoHangTheoHoaHonNhap dh1 = new Entities.ChiTietKhoHangTheoHoaHonNhap(" ", dh[i].Makho, dh[i].Mahanghoa, soluongupdate);
                 CongSoLuong(dh1);
             }
         }
     }
     catch
     {
         return 0;
     }
     return 1;
 }
 public void CheckDataGridTruSL(DataGridView dgv, string maKho)
 {
     if (dgv.RowCount != 0)
     {
         Entities.ChiTietKhoHangTheoHoaHonNhap[] cthdbh = new Entities.ChiTietKhoHangTheoHoaHonNhap[dgv.RowCount];
         for (int j = 0; j < cthdbh.Length; j++)
         {
             cthdbh[j] = new Entities.ChiTietKhoHangTheoHoaHonNhap("Update", maKho, dgv["MaHangHoa", j].Value.ToString(), int.Parse(dgv["SoLuong", j].Value.ToString()));
         }
         TruSLMang(cthdbh);
     }
 }
 public int LuuLai(Entities.ChiTietKhoHangTheoHoaHonNhap[] ddh)
 {
     int tra = 0;
     List<int> error = new List<int>();
     try
     {
         for (int i = 0; i < ddh.Length; i++)
         {
             Entities.ChiTietKhoHangTheoHoaHonNhap tl = new Entities.ChiTietKhoHangTheoHoaHonNhap();
             tl.Hanhdong = ddh[i].Hanhdong;
             tl.Makho = ddh[i].Makho;
             tl.Mahanghoa = ddh[i].Mahanghoa;
             tl.Soluong = ddh[i].Soluong;
             tl.Ngaynhap = ddh[i].Ngaynhap;
             tl.Ngayhethan = ddh[i].Ngayhethan;
             tl.Ghichu = ddh[i].Ghichu;
             tl.Deleted = ddh[i].Deleted;
             tl.Gia = ddh[i].Gia;
             int _return = sp_XuLy_ChiTietHoaDonNhapKho(tl);
             if (_return == 0)
             {
                 error.Add(i);
             }
         }
         if (error.Count == 0)
         {
             tra = 1;    //Không có lỗi gì
         }
         else
         {
             if (error.Count < ddh.Length)
             {
                 tra = -1;   //Có một số lỗi
             }
         }
     }
     catch { tra = 0; }
     return tra;
 }
        public Entities.ChiTietKhoHangTheoHoaHonNhap[] SelectTheoMaKho(String MaKho)
        {
            Entities.ChiTietKhoHangTheoHoaHonNhap[] arrC = null;
            try
            {
                string sql = "";
                sql = "Select * from ChiTietKhoHang where MaKho ='" + MaKho + "' and Deleted=0";
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    Entities.ChiTietKhoHangTheoHoaHonNhap ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap();
                    ctkho.Makho = dr["MaKho"].ToString();
                    ctkho.Mahanghoa = dr["MaHangHoa"].ToString();
                    ctkho.Soluong = Convert.ToInt32(dr["SoLuong"].ToString());
                    ctkho.Ngaynhap = DateTime.Parse(dr["NgayNhap"].ToString());
                    ctkho.Ngayhethan = DateTime.Parse(dr["HanSuDung"].ToString());
                    ctkho.Ghichu = dr["GhiChu"].ToString();
                    arr.Add(ctkho);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new Entities.ChiTietKhoHangTheoHoaHonNhap[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.ChiTietKhoHangTheoHoaHonNhap)arr[i];
                }
            }

            catch (Exception ex)
            {
                string s = ex.Message.ToString();
            }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return arrC;
        }
Ejemplo n.º 23
0
        public void LayChiTiet_HangHoaXuat_TheoKho(string maKho, string tenKho)
        {
            try
            {
                int count = 0;
                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    if (ctHangHoaTheoKho[i].Makho == maKho)
                    {
                        count++;
                    }
                }
                Entities.ChiTietKhoHangTheoHoaHonNhap[] ctkho = new Entities.ChiTietKhoHangTheoHoaHonNhap[count];
                count = 0;

                for (int i = 0; i < ctHangHoaTheoKho.Length; i++)
                {
                    if (ctHangHoaTheoKho[i].Makho == maKho)
                    {
                        ctkho[count] = ctHangHoaTheoKho[i];
                        count++;
                    }
                }

                ctBCXH = new Entities.CTBCNhapHangTheoKho[count];
                for (int i = 0; i < ctkho.Length; i++)
                {
                    ctBCXH[i] = new Entities.CTBCNhapHangTheoKho();
                    ctBCXH[i].MaKho = ctkho[i].Makho;
                    ctBCXH[i].TenKho = tenKho;
                    ctBCXH[i].MaHangHoa = ctkho[i].Mahanghoa;
                    ctBCXH[i].TongSoLuongNhap = 0;
                    for (int j = 0; j < HangHoa.Length; j++)
                    {
                        if (HangHoa[j].MaHangHoa == ctBCXH[i].MaHangHoa)
                        {
                            ctBCXH[i].TenHangHoa = HangHoa[j].TenHangHoa;
                            break;
                        }
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 24
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);
        }