Example #1
0
        public void checkConflict()
        {
            Server_Client.Client client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.HangHoa hh = new Entities.HangHoa("Select");
            Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
            networkStream = client.SerializeObj(this.tcpClient, "NhanVien", hh);

            hh1 = (Entities.HangHoa[])client.DeserializeHepper1(networkStream, hh1);
            if (hh1 != null)
            {
                for (int j = 0; j < hh1.Length; j++)
                {
                    if (hh1[j].MaHangHoa == txtMaHangHoa.Text)
                    {
                        MessageBox.Show("Thất bại");
                        chck = "No";
                        txtMaHangHoa.Text = new Common.Utilities().ProcessID(txtMaHangHoa.Text);
                        break;
                    }
                    else
                        chck = "Yes";
                }
            }
        }
        public void checkConflict()
        {
            Server_Client.Client client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.HangHoa   hh  = new Entities.HangHoa("Select");
            Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
            networkStream = client.SerializeObj(this.tcpClient, "NhanVien", hh);

            hh1 = (Entities.HangHoa[])client.DeserializeHepper1(networkStream, hh1);
            if (hh1 != null)
            {
                for (int j = 0; j < hh1.Length; j++)
                {
                    if (hh1[j].MaHangHoa == txtMaHangHoa.Text)
                    {
                        MessageBox.Show("Thất bại");
                        chck = "No";
                        txtMaHangHoa.Text = new Common.Utilities().ProcessID(txtMaHangHoa.Text);
                        break;
                    }
                    else
                    {
                        chck = "Yes";
                    }
                }
            }
        }
Example #3
0
 public Entities.HangHoa[] HangHoaTheoKho(string makho)
 {
     Entities.HangHoa[] hanghoa = new BizLogic.HangHoa().SelectHHTheoKho(makho);
     if (hanghoa == null)
     {
         hanghoa = new Entities.HangHoa[0];
     }
     return(hanghoa);
 }
Example #4
0
        public void Select()
        {
            try
            {
                dtgvKH.RowHeadersVisible = false;
                Server_Client.Client cl = new Server_Client.Client();
                cl           = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("HH");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                Entities.HangHoa[] kh1 = new Entities.HangHoa[0];
                kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
                if (kh1 == null)
                {
                    hienthi           = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                Entities.HangHoa[] ncc2 = new Entities.HangHoa[kh1.Length];
                int sotang = 0;
                for (int j = 0; j < kh1.Length; j++)
                {
                    if (kh1[j].Deleted == false)
                    {
                        ncc2[sotang] = kh1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.HangHoa[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = ncc2[j];
                    }
                }
                else
                {
                    hienthi           = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                dtgvKH.DataSource       = hienthi;
                dtgvKH.Rows[0].Selected = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                fix1();
            }
        }
Example #5
0
        public Entities.HangHoa[] SelectHHTheoKho(string maKho)
        {
            List <Entities.HangHoa> l = new List <Entities.HangHoa>();

            try
            {
                cn  = new Connection().openConnection();
                cmd = new SqlCommand("exec sp_HangHoaFIX @ThaoTac,@MaHangHoa,@MaNhomHangHoa,@TenHangHoa,@MaDonViTinh,@GiaNhap,@GiaBanBuon,@GiaBanLe,@MaThueGiaTriGiaTang,@KieuHangHoa,@SeriLo,@MucDatHang,@MucTonToiThieu,@GhiChu,@Deleted", cn);
                Entities.HangHoa input = new Entities.HangHoa();
                input.ThaoTac = "select_TheoKho";
                input.GhiChu  = maKho;
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value             = input.ThaoTac;
                cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar).Value            = input.MaHangHoa;
                cmd.Parameters.Add("MaNhomHangHoa", SqlDbType.NVarChar).Value       = input.MaNhomHangHoa;
                cmd.Parameters.Add("TenHangHoa", SqlDbType.NVarChar).Value          = input.TenHangHoa;
                cmd.Parameters.Add("MaDonViTinh", SqlDbType.NVarChar).Value         = input.MaDonViTinh;
                cmd.Parameters.Add("GiaNhap", SqlDbType.Float).Value                = 0;
                cmd.Parameters.Add("GiaBanBuon", SqlDbType.Float).Value             = 0;
                cmd.Parameters.Add("GiaBanLe", SqlDbType.Float).Value               = 0;
                cmd.Parameters.Add("MaThueGiaTriGiaTang", SqlDbType.NVarChar).Value = input.MaThueGiaTriGiaTang;
                cmd.Parameters.Add("KieuHangHoa", SqlDbType.NVarChar).Value         = input.KieuHangHoa;
                cmd.Parameters.Add("SeriLo", SqlDbType.NVarChar).Value              = input.SeriLo;
                cmd.Parameters.Add("MucDatHang", SqlDbType.NVarChar).Value          = input.MucDatHang;
                cmd.Parameters.Add("MucTonToiThieu", SqlDbType.NVarChar).Value      = input.MucTonToiThieu;
                cmd.Parameters.Add("GhiChu", SqlDbType.NVarChar).Value              = input.GhiChu;
                cmd.Parameters.Add("Deleted", SqlDbType.Bit).Value = input.Deleted;
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    hanghoa                     = new Entities.HangHoa();
                    hanghoa.MaHangHoa           = dr[Constants.HangHoaSTATIC.MaHangHoa].ToString();
                    hanghoa.MaNhomHangHoa       = dr[Constants.HangHoaSTATIC.MaNhomHangHoa].ToString();
                    hanghoa.TenHangHoa          = dr[Constants.HangHoaSTATIC.TenHangHoa].ToString();
                    hanghoa.MaDonViTinh         = dr[Constants.HangHoaSTATIC.MaDonViTinh].ToString();
                    hanghoa.TenDonViTinh        = dr[Constants.HangHoaSTATIC.TenDonViTinh].ToString();
                    hanghoa.GiaNhap             = dr[Constants.HangHoaSTATIC.GiaNhap].ToString();
                    hanghoa.GiaBanBuon          = dr[Constants.HangHoaSTATIC.GiaBanBuon].ToString();
                    hanghoa.GiaBanLe            = dr[Constants.HangHoaSTATIC.GiaBanLe].ToString();
                    hanghoa.MaThueGiaTriGiaTang = dr[Constants.HangHoaSTATIC.MaThueGiaTriGiaTang].ToString();
                    hanghoa.KieuHangHoa         = dr[Constants.HangHoaSTATIC.KieuHangHoa].ToString();
                    hanghoa.SeriLo              = dr[Constants.HangHoaSTATIC.SeriLo].ToString();
                    hanghoa.MucDatHang          = Convert.ToInt32(dr[Constants.HangHoaSTATIC.MucDatHang].ToString());
                    hanghoa.MucTonToiThieu      = Convert.ToInt32(dr[Constants.HangHoaSTATIC.MucTonToiThieu].ToString());
                    hanghoa.GhiChu              = dr[Constants.HangHoaSTATIC.GhiChu].ToString();
                    l.Add(hanghoa);
                }
            }
            catch { return(null); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
            }
            return(l.ToArray());
        }
Example #6
0
 public HangHoa()
 {
     hh      = null;
     Sql     = null;
     conn    = null;
     cmd     = null;
     arr     = null;
     dr      = null;
     hanghoa = null;
     cn      = null;
 }
Example #7
0
 public HangHoa()
 {
     hh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     hanghoa = null;
     cn = null;
 }
Example #8
0
        public void SelectDataHHTK()
        {
            try
            {
                ArrayList array = new ArrayList();
                dtgvKH.RowHeadersVisible = false;
                Server_Client.Client cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.HangHoa   kh  = new Entities.HangHoa("SelectTheoKho", maKho);
                Entities.HangHoa[] kh1 = new Entities.HangHoa[1];
                clientstrem = cl.SerializeObj(this.client1, "HangHoa", kh);
                kh1         = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);

                if (kh1 == null)
                {
                    hienthi           = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }
                foreach (Entities.HangHoa item in kh1)
                {
                    if (item.Deleted == false)
                    {
                        array.Add(item);
                    }
                }
                if (array.Count != 0)
                {
                    Entities.HangHoa[] save = Common.Utilities.CheckGoiHang((Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa)), goihang, chitietgoihang);
                    foreach (Entities.HangHoa item in save)
                    {
                        array.Add(item);
                    }
                    hienthi = (Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa));
                }
                else
                {
                    hienthi           = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                dtgvKH.DataSource       = hienthi;
                dtgvKH.Rows[0].Selected = true;
            }
            catch
            {
            }
            finally
            {
                fix();
            }
        }
Example #9
0
 public void LayBangHangHoa()
 {
     cl          = new Server_Client.Client();
     this.client = cl.Connect(Luu.IP, Luu.Ports);
     clientstrem = cl.SerializeObj(this.client, "Select", new Entities.CheckRefer("HH", ""));
     Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
     hh1 = (Entities.HangHoa[])cl.DeserializeHepper(clientstrem, hh1);
     if (hh1 == null)
     {
         hanghoa = new Entities.HangHoa[0];
     }
     hanghoa = hh1;
 }
Example #10
0
 public void LayBangHangHoa()
 {
     Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
     hh1 = new BizLogic.HangHoa().Select();
     if (hh1 != null)
     {
         hanghoa = hh1;
     }
     else
     {
         hanghoa = new Entities.HangHoa[0];
     }
 }
        //Xử Lý Thêm
        #region Xử Lý Thêm
        private void btnThem_Click(object sender, EventArgs e)
        {
            Server_Client.Client client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
            Entities.HangHoa hh = new Entities.HangHoa();
            //hh = new Entities.HangHoa("Insert", 0, txtMaHangHoa.Text,txtMaNhomHangHoa.Text,txtTenHangHoa.Text,cmbMaNhaSanXuat.SelectedItem.ToString(),txtMaVachNSX.Text,cmbMaDonViTinh.SelectedItem.ToString(),int.Parse(txtGiaNhap.Text),int.Parse(txtGiaBanBuon.Text),int.Parse(txtGiaBanLe.Text),cmbMaThueGTGT.SelectedItem.ToString(),cmbKieuHangHoa.SelectedItem.ToString(),txtSeri.Text,int.Parse(txtMucDatHang.Text),int.Parse(txtMucTonToiThieu.Text),txtGhiChu.Text,false);
            networkStream = client.SerializeObj(this.tcpClient, "HangHoa", hh);
            bool kt = false;

            kt = (bool)client.DeserializeHepper(networkStream, kt);
            if (kt == true)
            {
                MessageBox.Show("Thành công");
            }
            this.Close();
        }
Example #12
0
 public void LayHangHoa()
 {
     try
     {
         cl          = new Server_Client.Client();
         this.client = cl.Connect(Luu.IP, Luu.Ports);
         Entities.HangHoa ctxh = new Entities.HangHoa("Select");
         clientstrem = cl.SerializeObj(this.client, "HangHoa", ctxh);
         HangHoa     = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, HangHoa);
         if (HangHoa == null)
         {
             HangHoa = new Entities.HangHoa[0];
             return;
         }
     }
     catch { }
 }
Example #13
0
 //Sửa Hàng Hóa
 #region Xử lý Khi Sửa
 private void tssSua_Click(object sender, EventArgs e)
 {
     if (KiemTra() == true)
     {
         Server_Client.Client client = new Server_Client.Client();
         this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
         Entities.HangHoa hh = new Entities.HangHoa();
         hh            = new Entities.HangHoa("Update", int.Parse(txtHangHoaID.Text), txtMaHangHoa.Text, txtMaNhomHang.Text, txtTenHangHoa.Text, cmbMaNhaSanXuat.Text, txtMaVachNSX.Text, cmbMaDonViTinh.Text, float.Parse(txtGiaNhap.Text), float.Parse(txtGiaBanBuon.Text), float.Parse(txtGiaBanLe.Text), cmbMathueNhapKhau.Text, cmbMaThueXuatKhau.Text, cmbMaThueTieuThuDacBiet.Text, cmbMaThueGTGT.Text, txtKieuHangHoa.Text, txtSeri.Text, int.Parse(txtMucDatHang.Text), int.Parse(txtMucTonToiThieu.Text), txtChiTietThem.Text, txtNgungTheoDoi.Text, txtGhiChu.Text, false);
         networkStream = client.SerializeObj(this.tcpClient, "HangHoa", hh);
         bool kt = false;
         kt = (bool)client.DeserializeHepper(networkStream, kt);
         if (kt == true)
         {
             MessageBox.Show("Thành công");
         }
         this.Close();
     }
 }
Example #14
0
        //delete
        public int Delete(Entities.HangHoa hh1)
        {
            hh = new Constants.HangHoa();
            Entities.HangHoa hanghoa = new Entities.HangHoa();
            Sql = new Constants.Sql();
            string sql = Sql.DeleteHangHoa;
            Connection conn = new Connection();
            SqlConnection cn = conn.openConnection();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.Parameters.Add(hh.HanhDong, SqlDbType.NVarChar, 20).Value = hh1.HanhDong;
            cmd.Parameters.Add(hh.HangHoaID, SqlDbType.Int).Value = hh1.HangHoaID;

            int i = cmd.ExecuteNonQuery();
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn = null;
            conn = null;
            return i;
        }
Example #15
0
        //delete
        public int Delete(Entities.HangHoa hh1)
        {
            hh = new Constants.HangHoa();
            Entities.HangHoa hanghoa = new Entities.HangHoa();
            Sql = new Constants.Sql();
            string        sql  = Sql.DeleteHangHoa;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);

            cmd.Parameters.Add(hh.HanhDong, SqlDbType.NVarChar, 20).Value = hh1.HanhDong;
            cmd.Parameters.Add(hh.HangHoaID, SqlDbType.Int).Value         = hh1.HangHoaID;

            int i = cmd.ExecuteNonQuery();

            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
            return(i);
        }
Example #16
0
        //insert update
        public int InsertUpdate(Entities.HangHoa hh1)
        {
            try
            {
                hh  = new Constants.HangHoa();
                Sql = new Constants.Sql();
                string        sql  = Sql.InsertUpdateHangHoa;
                Connection    conn = new Connection();
                SqlConnection cn   = conn.openConnection();
                SqlCommand    cmd  = new SqlCommand(sql, cn);
                cmd.Parameters.Add(hh.HanhDong, SqlDbType.NVarChar, 20).Value      = hh1.HanhDong;
                cmd.Parameters.Add(hh.MaHangHoa, SqlDbType.NVarChar, 50).Value     = hh1.MaHangHoa;
                cmd.Parameters.Add(hh.MaNhomHangHoa, SqlDbType.NVarChar, 20).Value = hh1.MaNhomHangHoa;
                cmd.Parameters.Add(hh.TenHangHoa, SqlDbType.NVarChar, 200).Value   = hh1.TenHangHoa;
                cmd.Parameters.Add(hh.MaDonViTinh, SqlDbType.NVarChar, 20).Value   = hh1.MaDonViTinh;
                cmd.Parameters.Add(hh.GiaNhap, SqlDbType.Float).Value    = hh1.GiaNhap;
                cmd.Parameters.Add(hh.GiaBanBuon, SqlDbType.Float).Value = hh1.GiaBanBuon;
                cmd.Parameters.Add(hh.GiaBanLe, SqlDbType.Float).Value   = hh1.GiaBanLe;
                cmd.Parameters.Add(hh.MaThueGiaTriGiaTang, SqlDbType.NVarChar, 20).Value = hh1.MaThueGiaTriGiaTang;
                cmd.Parameters.Add(hh.KieuHangHoa, SqlDbType.NVarChar, 20).Value         = hh1.KieuHangHoa;
                cmd.Parameters.Add(hh.SeriLo, SqlDbType.NVarChar, 20).Value  = hh1.SeriLo;
                cmd.Parameters.Add(hh.MucDatHang, SqlDbType.Int).Value       = hh1.MucDatHang;
                cmd.Parameters.Add(hh.MucTonToiThieu, SqlDbType.Int).Value   = hh1.MucTonToiThieu;
                cmd.Parameters.Add(hh.GhiChu, SqlDbType.NVarChar, 100).Value = hh1.GhiChu;
                cmd.Parameters.Add(hh.Deleted, SqlDbType.Bit).Value          = hh1.Deleted;

                int i = cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn   = null;
                conn = null;
                return(i);
            }
            catch { return(0); }
        }
Example #17
0
 public void LayBangHangHoa()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client = cl.Connect(Luu.IP, Luu.Ports);
         clientstrem = cl.SerializeObj(this.client, "Select", new Entities.CheckRefer("HH", ""));
         Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
         hh1 = (Entities.HangHoa[])cl.DeserializeHepper(clientstrem, hh1);
         if (hh1 == null)
         {
             hanghoa = new Entities.HangHoa[0];
             return;
         }
         hanghoa = hh1;
     }
     catch { }
 }
        /// <summary>
        /// lấy hàng hóa theo mã
        /// </summary>
        private void LayHangHoaTheoMa()
        {
            Entities.HangHoa[] kh1;
            try
            {
                ArrayList array = new ArrayList();
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                Entities.HangHoa kh = new Entities.HangHoa();
                string makho = LayMaKho(cbxMaKho.Text);
                kh = new Entities.HangHoa("SelectTheoKho", makho);
                clientstrem = cl.SerializeObj(this.client1, "HangHoa", kh);
                kh1 = new Entities.HangHoa[1];
                kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
                if (kh1 == null)
                    kh1 = new Entities.HangHoa[0];

                if (kh1.Length > 0)
                {
                    foreach (Entities.HangHoa item in kh1)
                    {
                        array.Add(item);
                    }
                    Entities.HangHoa[] save = Common.Utilities.CheckGoiHang(kh1, goihang, chitietgoihang);
                    foreach (Entities.HangHoa item in save)
                    {
                        array.Add(item);
                    }
                    kh1 = (Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa));

                    bool ktdata = false;
                    int sl = kh1.Length;
                    for (int i = 0; i < sl; i++)
                    {
                        if (kh1[i].Deleted == false)
                            if (kh1[i].MaHangHoa.ToUpper() == toolStrip_txtTracuu.Text.ToUpper())
                            {

                                mahanghoa = toolStrip_txtTracuu.Text = kh1[i].MaHangHoa.ToUpper();
                                toolStrip_txtTenhang.Text = kh1[i].TenHangHoa;
                                toolStrip_txtGiagoc.Text = kh1[i].GiaBanBuon.ToString();
                                try
                                {
                                    SelectMaCapNhatKH();
                                    KiemTraCK(cngkh);
                                }
                                catch
                                {
                                    phantramchietkhau = toolStrip_txtChietkhauphantram.Text = "0";
                                }
                                LayGiaTriThue(kh1[i].MaThueGiaTriGiaTang);
                                toolStrip_txtTracuu.ReadOnly = true;
                                toolStrip_txtSoluong.Focus();
                                ktdata = true;
                                break;
                            }
                    }
                    if (ktdata == false)
                    {
                        MessageBox.Show("Không có hàng hóa trong kho", "Hệ thống cảnh báo");
                        toolStrip_txtTenhang.Text = "";
                        toolStrip_txtGiagoc.Text = "0";
                        toolStrip_txtChietkhauphantram.Text = "0";
                        toolStrip_txtThuegiatrigiatang.Text = "0";
                        toolStrip_txtTracuu.ReadOnly = false;
                    }
                }
                else
                {
                    MessageBox.Show("Không có hàng hóa trong kho", "Hệ thống cảnh báo");
                    toolStrip_txtTenhang.Text = "";
                    toolStrip_txtGiagoc.Text = "0";
                    toolStrip_txtChietkhauphantram.Text = "0";
                    toolStrip_txtThuegiatrigiatang.Text = "0";
                    toolStrip_txtTracuu.ReadOnly = false;
                }
            }
            catch
            {
                return;
            }
            finally
            {

            }
        }
        public Entities.BCNhapHangTheoNhomHang Select()
        {
            Entities.BCNhapHangTheoNhomHang list = null;
            try
            {
                list = new Entities.BCNhapHangTheoNhomHang();

                ////Lấy hóa đơn nhập
                //con = new Connection();
                //cn = con.openConnection();
                //List<Entities.HoaDonNhap> HoaDonNhap = new List<Entities.HoaDonNhap>();
                //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HoaDonNhap";
                //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                //while (dr.Read())
                //{
                //    Entities.HoaDonNhap row = new Entities.HoaDonNhap();
                //    row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString();
                //    row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString());
                //    HoaDonNhap.Add(row);
                //}
                //list.HoaDonNhap = HoaDonNhap;
                //cmd.Connection.Dispose();
                //cn.Close();
                //con.closeConnection();

                //Lấy chi tiết hóa đơn nhập
                con = new Connection();
                cn  = con.openConnection();
                List <Entities.ChiTietHoaDonNhap> ChiTietHoaDonNhap = new List <Entities.ChiTietHoaDonNhap>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietHoaDonNhap";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.ChiTietHoaDonNhap row = new Entities.ChiTietHoaDonNhap();
                    row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString();
                    row.MaHangHoa    = dr["MaHangHoa"].ToString();
                    row.SoLuong      = int.Parse(dr["SoLuong"].ToString());
                    row.NgayNhap     = DateTime.Parse(dr["NgayNhap"].ToString());
                    ChiTietHoaDonNhap.Add(row);
                }
                list.ChiTietHoaDonNhap = ChiTietHoaDonNhap;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                ////Lấy khách hàng trả lại
                //con = new Connection();
                //cn = con.openConnection();
                //List<Entities.KhachHangTraLai> KhachHangTraLai = new List<Entities.KhachHangTraLai>();
                //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "KhachHangTraLai";
                //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                //while (dr.Read())
                //{
                //    Entities.KhachHangTraLai row = new Entities.KhachHangTraLai();
                //    row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString();
                //    row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString());
                //    KhachHangTraLai.Add(row);
                //}
                //list.KhachHangTraLai = KhachHangTraLai;
                //cmd.Connection.Dispose();
                //cn.Close();
                //con.closeConnection();

                //Lấy chi tiết khách hàng trả lại
                con = new Connection();
                cn  = con.openConnection();
                List <Entities.ChiTietKhachHangTraLai> ChiTietKhachHangTraLai = new List <Entities.ChiTietKhachHangTraLai>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietKhachHangTraLai";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.ChiTietKhachHangTraLai row = new Entities.ChiTietKhachHangTraLai();
                    row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString();
                    row.MaHangHoa         = dr["MaHangHoa"].ToString();
                    row.SoLuong           = int.Parse(dr["SoLuong"].ToString());
                    row.NgayNhap          = DateTime.Parse(dr["NgayNhap"].ToString());
                    ChiTietKhachHangTraLai.Add(row);
                }
                list.ChiTietKhachHangTraLai = ChiTietKhachHangTraLai;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy hàng hóa nhóm hàng
                con = new Connection();
                cn  = con.openConnection();
                List <Entities.HangHoa> HangHoa = new List <Entities.HangHoa>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HangHoaNhomHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.HangHoa row = new Entities.HangHoa();
                    row.MaHangHoa      = dr["MaHangHoa"].ToString();
                    row.TenHangHoa     = dr["TenHangHoa"].ToString();
                    row.MaNhomHangHoa  = dr["MaNhomHang"].ToString();
                    row.TenNhomHangHoa = dr["TenNhomHang"].ToString();
                    HangHoa.Add(row);
                }
                list.HangHoa = HangHoa;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy nhóm hàng
                con = new Connection();
                cn  = con.openConnection();
                List <Entities.NhomHang> NhomHang = new List <Entities.NhomHang>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "NhomHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.NhomHang row = new Entities.NhomHang();
                    row.MaNhomHang  = dr["MaNhomHang"].ToString();
                    row.TenNhomHang = dr["TenNhomHang"].ToString();
                    NhomHang.Add(row);
                }
                list.NhomHang = NhomHang;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy gói hàng
                con = new Connection();
                cn  = con.openConnection();
                List <Entities.GoiHang> GoiHang = new List <Entities.GoiHang>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "GoiHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.GoiHang row = new Entities.GoiHang();
                    row.MaGoiHang = dr["MaGoiHang"].ToString();
                    GoiHang.Add(row);
                }
                list.GoiHang = GoiHang;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy chi tiết gói hàng
                con = new Connection();
                cn  = con.openConnection();
                List <Entities.ChiTietGoiHang> ChiTietGoiHang = new List <Entities.ChiTietGoiHang>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietGoiHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.ChiTietGoiHang row = new Entities.ChiTietGoiHang();
                    row.MaGoiHang = dr["MaGoiHang"].ToString();
                    row.MaHangHoa = dr["MaHangHoa"].ToString();
                    row.SoLuong   = int.Parse(dr["SoLuong"].ToString());
                    ChiTietGoiHang.Add(row);
                }
                list.ChiTietGoiHang = ChiTietGoiHang;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();
            }
            catch { return(null); }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();
            }
            return(list);
        }
        public void SelectData()
        {
            try
            {
                dgvHangHoa.RowHeadersVisible = false;
                cl = new Server_Client.Client();
                this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                Entities.HangHoa hh = new Entities.HangHoa("Select");
                networkStream = cl.SerializeObj(this.tcpClient, "HangHoa", hh);
                Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
                hh1 = (Entities.HangHoa[])cl.DeserializeHepper1(networkStream, hh1);

                // goi hang
                cl = new Server_Client.Client();
                this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("GH");
                networkStream = cl.SerializeObj(this.tcpClient, "Select", ctxh);
                Entities.GoiHang[] goihang = new Entities.GoiHang[0];
                goihang = (Entities.GoiHang[])cl.DeserializeHepper1(networkStream, goihang);

                if (hh1 == null && goihang == null)
                {
                    dgvHangHoa.DataSource = new Entities.HangHoa[0];
                    return;
                }

                List<Entities.HangHoa> listHangHoa = new List<Entities.HangHoa>();

                // for hang hoa
                foreach (Entities.HangHoa hanghoa in hh1)
                {
                    if (hanghoa != null && hanghoa.Deleted == false && hanghoa.MaNhomHangHoa.Equals(manhomhang))
                    {
                        listHangHoa.Add(hanghoa);
                    }
                }

                // for goi hang
                foreach (Entities.GoiHang gh in goihang)
                {
                    if (gh != null && gh.Deleted == false && gh.MaNhomHang.Equals(manhomhang))
                    {
                        Entities.HangHoa hanghoa = new Entities.HangHoa();
                        hanghoa.MaHangHoa = gh.MaGoiHang;
                        hanghoa.TenHangHoa = gh.TenGoiHang;
                        hanghoa.MaNhomHangHoa = gh.MaNhomHang;
                        hanghoa.GiaNhap = gh.GiaNhap;
                        hanghoa.GiaBanBuon = gh.GiaBanBuon;
                        hanghoa.GiaBanLe = gh.GiaBanLe;
                        listHangHoa.Add(hanghoa);

                    }
                }
                dgvHangHoa.DataSource = (Entities.HangHoa[])listHangHoa.ToArray();
                dgvHangHoa.Rows[0].Selected = true;

            }
            catch (Exception ex)
            {

            }
            finally
            {
                fix1();
            }
        }
Example #21
0
 //Entities
 public Entities.HangHoa[] sp_SelectHangHoasAll(Entities.HangHoa input)
 {
     List<Entities.HangHoa> l = new List<Entities.HangHoa>();
     try
     {
         cn = new Connection().openConnection();
         cmd = new SqlCommand("exec sp_HangHoaFIX @ThaoTac,@MaHangHoa,@MaNhomHangHoa,@TenHangHoa,@MaDonViTinh,@GiaNhap,@GiaBanBuon,@GiaBanLe,@MaThueGiaTriGiaTang,@KieuHangHoa,@SeriLo,@MucDatHang,@MucTonToiThieu,@GhiChu,@Deleted", cn);
         cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = input.ThaoTac;
         cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar).Value = input.MaHangHoa;
         cmd.Parameters.Add("MaNhomHangHoa", SqlDbType.NVarChar).Value = input.MaNhomHangHoa;
         cmd.Parameters.Add("TenHangHoa", SqlDbType.NVarChar).Value = input.TenHangHoa;
         cmd.Parameters.Add("MaDonViTinh", SqlDbType.NVarChar).Value = input.MaDonViTinh;
         cmd.Parameters.Add("GiaNhap", SqlDbType.Float).Value = 0;
         cmd.Parameters.Add("GiaBanBuon", SqlDbType.Float).Value = 0;
         cmd.Parameters.Add("GiaBanLe", SqlDbType.Float).Value = 0;
         cmd.Parameters.Add("MaThueGiaTriGiaTang", SqlDbType.NVarChar).Value = input.MaThueGiaTriGiaTang;
         cmd.Parameters.Add("KieuHangHoa", SqlDbType.NVarChar).Value = input.KieuHangHoa;
         cmd.Parameters.Add("SeriLo", SqlDbType.NVarChar).Value = input.SeriLo;
         cmd.Parameters.Add("MucDatHang", SqlDbType.NVarChar).Value = input.MucDatHang;
         cmd.Parameters.Add("MucTonToiThieu", SqlDbType.NVarChar).Value = input.MucTonToiThieu;
         cmd.Parameters.Add("GhiChu", SqlDbType.NVarChar).Value = input.GhiChu;
         cmd.Parameters.Add("Deleted", SqlDbType.Bit).Value = input.Deleted;
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         while (dr.Read())
         {
             hanghoa = new Entities.HangHoa();
             hanghoa.HangHoaID = int.Parse(dr[Constants.HangHoaSTATIC.HangHoaID].ToString());
             hanghoa.MaHangHoa = dr[Constants.HangHoaSTATIC.MaHangHoa].ToString();
             hanghoa.MaNhomHangHoa = dr[Constants.HangHoaSTATIC.MaNhomHangHoa].ToString();
             hanghoa.TenHangHoa = dr[Constants.HangHoaSTATIC.TenHangHoa].ToString();
             hanghoa.MaDonViTinh = dr[Constants.HangHoaSTATIC.MaDonViTinh].ToString();
             hanghoa.TenDonViTinh = dr[Constants.HangHoaSTATIC.TenDonViTinh].ToString();
             hanghoa.GiaNhap = dr[Constants.HangHoaSTATIC.GiaNhap].ToString();
             hanghoa.GiaBanBuon = dr[Constants.HangHoaSTATIC.GiaBanBuon].ToString();
             hanghoa.GiaBanLe = dr[Constants.HangHoaSTATIC.GiaBanLe].ToString();
             hanghoa.MaThueGiaTriGiaTang = dr[Constants.HangHoaSTATIC.MaThueGiaTriGiaTang].ToString();
             hanghoa.KieuHangHoa = dr[Constants.HangHoaSTATIC.KieuHangHoa].ToString();
             hanghoa.SeriLo = dr[Constants.HangHoaSTATIC.SeriLo].ToString();
             hanghoa.MucDatHang = Convert.ToInt32(dr[Constants.HangHoaSTATIC.MucDatHang].ToString());
             hanghoa.MucTonToiThieu = Convert.ToInt32(dr[Constants.HangHoaSTATIC.MucTonToiThieu].ToString());
             hanghoa.GhiChu = dr[Constants.HangHoaSTATIC.GhiChu].ToString();
             l.Add(hanghoa);
         }
     }
     catch { return null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
     }
     return l.ToArray();
 }
Example #22
0
        public void Select()
        {
            try
            {
                dtgvKH.RowHeadersVisible = false;
                Server_Client.Client cl = new Server_Client.Client();
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("HH");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                Entities.HangHoa[] kh1 = new Entities.HangHoa[0];
                kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
                if (kh1 == null)
                {
                    hienthi = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                Entities.HangHoa[] ncc2 = new Entities.HangHoa[kh1.Length];
                int sotang = 0;
                for (int j = 0; j < kh1.Length; j++)
                {
                    if (kh1[j].Deleted == false)
                    {
                        ncc2[sotang] = kh1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.HangHoa[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = ncc2[j];
                    }
                }
                else
                {
                    hienthi = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                dtgvKH.DataSource = hienthi;
                dtgvKH.Rows[0].Selected = true;
            }
            catch (Exception ex)
            {

            }
            finally
            {
                fix1();
            }
        }
Example #23
0
        public void SelectDataHHTK()
        {
            try
            {

                ArrayList array = new ArrayList();
                dtgvKH.RowHeadersVisible = false;
                Server_Client.Client cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.HangHoa kh = new Entities.HangHoa("SelectTheoKho", maKho);
                Entities.HangHoa[] kh1 = new Entities.HangHoa[1];
                clientstrem = cl.SerializeObj(this.client1, "HangHoa", kh);
                kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);

                if (kh1 == null)
                {
                    hienthi = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }
                foreach (Entities.HangHoa item in kh1)
                {
                    if (item.Deleted == false)
                        array.Add(item);
                }
                if (array.Count != 0)
                {
                    Entities.HangHoa[] save = Common.Utilities.CheckGoiHang((Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa)), goihang, chitietgoihang);
                    foreach (Entities.HangHoa item in save)
                    {
                        array.Add(item);
                    }
                    hienthi = (Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa));
                }
                else
                {
                    hienthi = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                dtgvKH.DataSource = hienthi;
                dtgvKH.Rows[0].Selected = true;
            }
            catch
            {
            }
            finally
            {

                fix();

            }
        }
Example #24
0
 public Entities.HangHoa[] SelectAll()
 {
     Entities.HangHoa temp = new Entities.HangHoa(); temp.ThaoTac = "select";
     return(sp_SelectHangHoasAll(temp));
 }
 public void LayBangHangHoa()
 {
     try
     {
         Entities.CheckRefer Checkrefer;
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Checkrefer = new Entities.CheckRefer("HH", "");
         clientstrem = cl.SerializeObj(this.client1, "Select", Checkrefer);
         Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
         hh1 = (Entities.HangHoa[])cl.DeserializeHepper(clientstrem, hh1);
         if (hh1 != null)
         {
             hanghoa = hh1;
         }
         else
         {
             hanghoa = new Entities.HangHoa[0];
         }
     }
     catch
     {
     }
 }
 /// <summary>
 /// select hàng hóa
 /// </summary>
 public void SelectHangHoa()
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         // khởi tạo biến truyền vào với hàm khởi tạo
         Entities.HangHoa pt = new Entities.HangHoa("Select");
         // khởi tạo mảng đối tượng để hứng giá trị
         hh1 = new Entities.HangHoa[1];
         clientstrem = cl.SerializeObj(this.client1, "HangHoa", pt);
         // đổ mảng đối tượng vào datagripview
         hh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, hh1);
     }
     catch { }
 }
Example #27
0
 public void LayHangHoa()
 {
     try
     {
         cl = new Server_Client.Client();
         this.client = cl.Connect(Luu.IP, Luu.Ports);
         Entities.HangHoa ctxh = new Entities.HangHoa("Select");
         clientstrem = cl.SerializeObj(this.client, "HangHoa", ctxh);
         HangHoa = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, HangHoa);
         if (HangHoa == null)
         {
             HangHoa = new Entities.HangHoa[0];
             return;
         }
     }
     catch { }
 }
        /// <summary>
        /// lấy hàng hóa
        /// </summary>
        private void LayHangHoaTheoMa()
        {
            Entities.HangHoa[] kh1;
            try
            {
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                Entities.HangHoa kh = new Entities.HangHoa();
                string makho = LayMaKho(cbbkhohang.Text);
                kh = new Entities.HangHoa("SelectTheoKho", makho);
                clientstrem = cl.SerializeObj(this.client1, "HangHoa", kh);
                kh1 = new Entities.HangHoa[1];
                kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
                if (kh1 == null)
                    kh1 = new Entities.HangHoa[0];

                if (kh1.Length > 0)
                {
                    bool ktdata = false;
                    int sl = kh1.Length;
                    for (int i = 0; i < sl; i++)
                    {
                        if (kh1[i].Deleted == false)
                            if (kh1[i].MaHangHoa == toolStrip_txtTracuu.Text)
                            {
                                mahanghoa = toolStrip_txtTracuu.Text = kh1[i].MaHangHoa;
                                tssltenhang.Text = kh1[i].TenHangHoa;
                                tsslgia.Text = kh1[i].GiaBanLe.ToString();
                                toolStrip_txtTracuu.ReadOnly = true;
                                tsslsoluong.Focus();
                                ktdata = true;
                                break;
                            }
                    }
                    if (ktdata == false)
                    {
                        tssltenhang.Text = "";
                        tsslgia.Text = "0";
                        tsslsoluong.Text = "";
                        tsslthanhtien.Text = "0";
                        toolStrip_txtTracuu.ReadOnly = false;
                        this.khongcohanghoatrongkho = true;
                    }
                }
                else
                {
                    tssltenhang.Text = "";
                    tsslgia.Text = "0";
                    tsslsoluong.Text = "";
                    tsslthanhtien.Text = "0";
                    toolStrip_txtTracuu.ReadOnly = false;
                    MessageBox.Show("Không có hàng hóa trong kho!");
                }
            }
            catch (Exception ex)
            {
                tssltenhang.Text = "";
                tsslgia.Text = "0";
                tsslsoluong.Text = "";
                tsslthanhtien.Text = "0";
                toolStrip_txtTracuu.ReadOnly = false;
            }
            finally
            {
                timerRun.Stop();
                run = 0;

            }
        }
Example #29
0
 public Entities.HangHoa[] SelectAll()
 {
     Entities.HangHoa temp = new Entities.HangHoa(); temp.ThaoTac = "select";
     return sp_SelectHangHoasAll(temp);
 }
Example #30
0
 public Entities.HangHoa[] SelectHangHoa_Theo_MaHangHoa(string mahanghoa)
 {
     Entities.HangHoa temp = new Entities.HangHoa(); temp.ThaoTac = "select_TheoMaHangHoa"; temp.MaHangHoa = mahanghoa.ToUpper();
     return(sp_SelectHangHoasAll(temp));
 }
Example #31
0
 /// <summary>
 /// Lay tat ca hang hoa theo kho
 /// </summary>
 /// <param name="maKho"></param>
 /// <returns></returns>
 public Entities.HangHoa[] GetHangHoaTheoKho(string maKho)
 {
     Entities.HangHoa hh = null;
     Entities.HangHoa[] hhArr = null;
     try
     {
         Server_Client.Client cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         hh = new Entities.HangHoa("SelectTheoKho", maKho);
         hhArr = new Entities.HangHoa[1];
         clientstrem = cl.SerializeObj(this.client1, "HangHoa", hh);
         hhArr = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, hhArr);
         return hhArr;
     }
     catch (Exception)
     {
         hhArr = null;
     }
     return hhArr;
 }
Example #32
0
        public Entities.HangHoa[] Select(string Cot, string Kieu, string Giatri)
        {
            Entities.HangHoa[] arrC = null;
            try
            {
                hh = new Constants.HangHoa();
                Sql = new Constants.Sql();
                string sql = "";
                if (Kieu == "like")
                    sql = "select * from HangHoa where " + Cot + " " + Kieu + " '%" + Giatri + "%' and Deleted =0 ";
                else
                    sql = "select * from HangHoa where " + Cot + " " + Kieu + " '" + Giatri + "'  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())
                {
                    hanghoa = new Entities.HangHoa();
                    hanghoa.HangHoaID = Convert.ToInt32(dr[hh.HangHoaID].ToString());
                    hanghoa.MaHangHoa = dr[hh.MaHangHoa].ToString();
                    hanghoa.MaNhomHangHoa = dr[hh.MaNhomHangHoa].ToString();
                    hanghoa.TenHangHoa = dr[hh.TenHangHoa].ToString();
                    hanghoa.MaDonViTinh = dr[hh.MaDonViTinh].ToString();
                    hanghoa.TenDonViTinh = LayDVT(hanghoa.MaDonViTinh);
                    hanghoa.GiaNhap = dr[hh.GiaNhap].ToString();
                    hanghoa.GiaBanBuon = dr[hh.GiaBanBuon].ToString();
                    hanghoa.GiaBanLe = dr[hh.GiaBanLe].ToString();
                    hanghoa.MaThueGiaTriGiaTang = dr[hh.MaThueGiaTriGiaTang].ToString();
                    hanghoa.KieuHangHoa = dr[hh.KieuHangHoa].ToString();
                    hanghoa.SeriLo = dr[hh.SeriLo].ToString();
                    hanghoa.MucDatHang = Convert.ToInt32(dr[hh.MucDatHang].ToString());
                    hanghoa.MucTonToiThieu = Convert.ToInt32(dr[hh.MucTonToiThieu].ToString());
                    hanghoa.GhiChu = dr[hh.GhiChu].ToString();
                    hanghoa.Deleted = (Boolean)dr[hh.Deleted];
                    arr.Add(hanghoa);
                }
                int n = arr.Count;
                if (n == 0) { return null; }
                arrC = new Entities.HangHoa[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.HangHoa)arr[i];
                }
            }

            catch { }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return arrC;
        }
 public void LayBangHangHoa()
 {
     Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
     hh1 = new BizLogic.HangHoa().Select();
     if (hh1 != null)
     {
         hanghoa = hh1;
     }
     else
     {
         hanghoa = new Entities.HangHoa[0];
     }
 }
Example #34
0
        public Entities.HangHoa[] Select(string Cot, string Kieu, string Giatri)
        {
            Entities.HangHoa[] arrC = null;
            try
            {
                hh  = new Constants.HangHoa();
                Sql = new Constants.Sql();
                string sql = "";
                if (Kieu == "like")
                {
                    sql = "select * from HangHoa where " + Cot + " " + Kieu + " '%" + Giatri + "%' and Deleted =0 ";
                }
                else
                {
                    sql = "select * from HangHoa where " + Cot + " " + Kieu + " '" + Giatri + "'  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())
                {
                    hanghoa                     = new Entities.HangHoa();
                    hanghoa.HangHoaID           = Convert.ToInt32(dr[hh.HangHoaID].ToString());
                    hanghoa.MaHangHoa           = dr[hh.MaHangHoa].ToString();
                    hanghoa.MaNhomHangHoa       = dr[hh.MaNhomHangHoa].ToString();
                    hanghoa.TenHangHoa          = dr[hh.TenHangHoa].ToString();
                    hanghoa.MaDonViTinh         = dr[hh.MaDonViTinh].ToString();
                    hanghoa.TenDonViTinh        = LayDVT(hanghoa.MaDonViTinh);
                    hanghoa.GiaNhap             = dr[hh.GiaNhap].ToString();
                    hanghoa.GiaBanBuon          = dr[hh.GiaBanBuon].ToString();
                    hanghoa.GiaBanLe            = dr[hh.GiaBanLe].ToString();
                    hanghoa.MaThueGiaTriGiaTang = dr[hh.MaThueGiaTriGiaTang].ToString();
                    hanghoa.KieuHangHoa         = dr[hh.KieuHangHoa].ToString();
                    hanghoa.SeriLo              = dr[hh.SeriLo].ToString();
                    hanghoa.MucDatHang          = Convert.ToInt32(dr[hh.MucDatHang].ToString());
                    hanghoa.MucTonToiThieu      = Convert.ToInt32(dr[hh.MucTonToiThieu].ToString());
                    hanghoa.GhiChu              = dr[hh.GhiChu].ToString();
                    hanghoa.Deleted             = (Boolean)dr[hh.Deleted];
                    arr.Add(hanghoa);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    return(null);
                }
                arrC = new Entities.HangHoa[n];
                for (int i = 0; i < n; i++)
                {
                    arrC[i] = (Entities.HangHoa)arr[i];
                }
            }

            catch { }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return(arrC);
        }
Example #35
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="isBanLe"></param>
        public void SelectData(bool isBanLe)
        {
            try
            {
                ArrayList array = new ArrayList();
                dtgvKH.RowHeadersVisible = false;
                Server_Client.Client cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.HangHoa kh = new Entities.HangHoa("SelectTheoKho", maKho);
                Entities.HangHoa[] kh1 = new Entities.HangHoa[1];
                clientstrem = cl.SerializeObj(this.client1, "HangHoa", kh);
                kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
                // gói hàng
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("GH");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                goihang = new Entities.GoiHang[0];
                goihang = (Entities.GoiHang[])cl.DeserializeHepper1(clientstrem, goihang);
                if (goihang == null)
                {
                    goihang = new Entities.GoiHang[0];
                    return;
                }

                // chi tiết gói hàng
                cl = new Server_Client.Client();
                this.client1 = cl.Connect(Luu.IP, Luu.Ports);
                ctxh = new Entities.CheckRefer("CTGH");
                clientstrem = cl.SerializeObj(this.client1, "Select", ctxh);
                chitietgoihang = new Entities.ChiTietGoiHang[0];
                chitietgoihang = (Entities.ChiTietGoiHang[])cl.DeserializeHepper1(clientstrem, chitietgoihang);
                if (chitietgoihang == null)
                {
                    chitietgoihang = new Entities.ChiTietGoiHang[0];
                    return;
                }

                if (kh1 == null)
                {
                    hienthi = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }
                foreach (Entities.HangHoa item in kh1)
                {
                    if (item.Deleted == false)
                        array.Add(item);
                }
                if (array.Count != 0)
                {
                    Entities.HangHoa[] save = Common.Utilities.CheckGoiHang((Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa)), goihang, chitietgoihang);
                    foreach (Entities.HangHoa item in save)
                    {
                        array.Add(item);
                    }
                    hienthi = (Entities.HangHoa[])array.ToArray(typeof(Entities.HangHoa));
                }
                else
                {
                    hienthi = new Entities.HangHoa[0];
                    dtgvKH.DataSource = new Entities.HangHoa[0];
                    return;
                }

                dtgvKH.DataSource = hienthi;
                dtgvKH.Rows[0].Selected = true;
            }
            catch
            {
            }
            finally
            {
                if (isBanLe)
                    fixBL();
                else
                    fixBB();
            }
        }
 private void btnThem_Click(object sender, EventArgs e)
 {
     Server_Client.Client client = new Server_Client.Client();
     this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
     Entities.HangHoa hh = new Entities.HangHoa();
     //hh = new Entities.HangHoa("Insert", 0, txtMaHangHoa.Text,txtMaNhomHangHoa.Text,txtTenHangHoa.Text,cmbMaNhaSanXuat.SelectedItem.ToString(),txtMaVachNSX.Text,cmbMaDonViTinh.SelectedItem.ToString(),int.Parse(txtGiaNhap.Text),int.Parse(txtGiaBanBuon.Text),int.Parse(txtGiaBanLe.Text),cmbMaThueGTGT.SelectedItem.ToString(),cmbKieuHangHoa.SelectedItem.ToString(),txtSeri.Text,int.Parse(txtMucDatHang.Text),int.Parse(txtMucTonToiThieu.Text),txtGhiChu.Text,false);
     networkStream = client.SerializeObj(this.tcpClient, "HangHoa", hh);
     bool kt = false;
     kt = (bool)client.DeserializeHepper(networkStream, kt);
     if (kt == true)
     {
         MessageBox.Show("Thành công");
     }
     this.Close();
 }
Example #37
0
        /// <summary>
        /// xử lý khi tìm kiếm
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txttimkiem_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // Tat ca
                if (rdbtimkiem3.Checked == true)
                {
                    return;
                }

                int soluong = 0;
                // Theo Ten san pham
                if (rdbtimkiem1.Checked == true)
                {
                    if (txttimkiem.Text.Length == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].TenHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            soluong++;
                        }
                    }
                    if (soluong == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    Entities.HangHoa[] hienthitheoid = new Entities.HangHoa[soluong];
                    soluong = 0;
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].TenHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            hienthitheoid[soluong] = hienthi[i];
                            soluong++;
                        }
                    }
                    dtgvKH.DataSource = hienthitheoid;
                }
                // Theo ma san pham
                if (rdbtimkiem2.Checked == true)
                {
                    if (txttimkiem.Text.Length == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].MaHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            soluong++;
                        }
                    }
                    if (soluong == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    Entities.HangHoa[] hienthitheoma = new Entities.HangHoa[soluong];
                    soluong = 0;
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].MaHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            hienthitheoma[soluong] = hienthi[i];
                            soluong++;
                        }
                    }
                    dtgvKH.DataSource = hienthitheoma;
                }
            }
            finally
            {
                // Ban le
                if (this.isBanLe)
                    fixBL();
                // ban buon
                else if (this.isBanBuon)
                    fixBB();
                // truong hop khac
                else
                    fix();
            }
        }
        public Entities.BCNhapHangTheoNhomHang Select()
        {
            Entities.BCNhapHangTheoNhomHang list = null;
            try
            {
                list = new Entities.BCNhapHangTheoNhomHang();

                ////Lấy hóa đơn nhập
                //con = new Connection();
                //cn = con.openConnection();
                //List<Entities.HoaDonNhap> HoaDonNhap = new List<Entities.HoaDonNhap>();
                //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HoaDonNhap";
                //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                //while (dr.Read())
                //{
                //    Entities.HoaDonNhap row = new Entities.HoaDonNhap();
                //    row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString();
                //    row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString());
                //    HoaDonNhap.Add(row);
                //}
                //list.HoaDonNhap = HoaDonNhap;
                //cmd.Connection.Dispose();
                //cn.Close();
                //con.closeConnection();

                //Lấy chi tiết hóa đơn nhập
                con = new Connection();
                cn = con.openConnection();
                List<Entities.ChiTietHoaDonNhap> ChiTietHoaDonNhap = new List<Entities.ChiTietHoaDonNhap>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietHoaDonNhap";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.ChiTietHoaDonNhap row = new Entities.ChiTietHoaDonNhap();
                    row.MaHoaDonNhap = dr["MaHoaDonNhap"].ToString();
                    row.MaHangHoa = dr["MaHangHoa"].ToString();
                    row.SoLuong = int.Parse(dr["SoLuong"].ToString());
                    row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString());
                    ChiTietHoaDonNhap.Add(row);
                }
                list.ChiTietHoaDonNhap = ChiTietHoaDonNhap;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                ////Lấy khách hàng trả lại
                //con = new Connection();
                //cn = con.openConnection();
                //List<Entities.KhachHangTraLai> KhachHangTraLai = new List<Entities.KhachHangTraLai>();
                //cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                //cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "KhachHangTraLai";
                //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                //while (dr.Read())
                //{
                //    Entities.KhachHangTraLai row = new Entities.KhachHangTraLai();
                //    row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString();
                //    row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString());
                //    KhachHangTraLai.Add(row);
                //}
                //list.KhachHangTraLai = KhachHangTraLai;
                //cmd.Connection.Dispose();
                //cn.Close();
                //con.closeConnection();

                //Lấy chi tiết khách hàng trả lại
                con = new Connection();
                cn = con.openConnection();
                List<Entities.ChiTietKhachHangTraLai> ChiTietKhachHangTraLai = new List<Entities.ChiTietKhachHangTraLai>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietKhachHangTraLai";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.ChiTietKhachHangTraLai row = new Entities.ChiTietKhachHangTraLai();
                    row.MaKhachHangTraLai = dr["MaKhachHangTraLai"].ToString();
                    row.MaHangHoa = dr["MaHangHoa"].ToString();
                    row.SoLuong = int.Parse(dr["SoLuong"].ToString());
                    row.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString());
                    ChiTietKhachHangTraLai.Add(row);
                }
                list.ChiTietKhachHangTraLai = ChiTietKhachHangTraLai;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy hàng hóa nhóm hàng
                con = new Connection();
                cn = con.openConnection();
                List<Entities.HangHoa> HangHoa = new List<Entities.HangHoa>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "HangHoaNhomHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.HangHoa row = new Entities.HangHoa();
                    row.MaHangHoa = dr["MaHangHoa"].ToString();
                    row.TenHangHoa = dr["TenHangHoa"].ToString();
                    row.MaNhomHangHoa = dr["MaNhomHang"].ToString();
                    row.TenNhomHangHoa = dr["TenNhomHang"].ToString();
                    HangHoa.Add(row);
                }
                list.HangHoa = HangHoa;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy nhóm hàng
                con = new Connection();
                cn = con.openConnection();
                List<Entities.NhomHang> NhomHang = new List<Entities.NhomHang>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "NhomHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.NhomHang row = new Entities.NhomHang();
                    row.MaNhomHang = dr["MaNhomHang"].ToString();
                    row.TenNhomHang = dr["TenNhomHang"].ToString();
                    NhomHang.Add(row);
                }
                list.NhomHang = NhomHang;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy gói hàng
                con = new Connection();
                cn = con.openConnection();
                List<Entities.GoiHang> GoiHang = new List<Entities.GoiHang>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "GoiHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.GoiHang row = new Entities.GoiHang();
                    row.MaGoiHang = dr["MaGoiHang"].ToString();
                    GoiHang.Add(row);
                }
                list.GoiHang = GoiHang;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

                //Lấy chi tiết gói hàng
                con = new Connection();
                cn = con.openConnection();
                List<Entities.ChiTietGoiHang> ChiTietGoiHang = new List<Entities.ChiTietGoiHang>();
                cmd = new SqlCommand("exec sp_BCNhapHangTheoNhomHangFIX @ThaoTac", cn);
                cmd.Parameters.Add("ThaoTac", SqlDbType.NVarChar).Value = "ChiTietGoiHang";
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    Entities.ChiTietGoiHang row = new Entities.ChiTietGoiHang();
                    row.MaGoiHang = dr["MaGoiHang"].ToString();
                    row.MaHangHoa = dr["MaHangHoa"].ToString();
                    row.SoLuong = int.Parse(dr["SoLuong"].ToString());
                    ChiTietGoiHang.Add(row);
                }
                list.ChiTietGoiHang = ChiTietGoiHang;
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();

            }
            catch { return null; }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                con.closeConnection();
            }
            return list;
        }
Example #39
0
        /// <summary>
        /// xử lý khi tìm kiếm
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txttimkiem_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // Tat ca
                if (rdbtimkiem3.Checked == true)
                {
                    return;
                }

                int soluong = 0;
                // Theo Ten san pham
                if (rdbtimkiem1.Checked == true)
                {
                    if (txttimkiem.Text.Length == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].TenHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            soluong++;
                        }
                    }
                    if (soluong == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    Entities.HangHoa[] hienthitheoid = new Entities.HangHoa[soluong];
                    soluong = 0;
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].TenHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            hienthitheoid[soluong] = hienthi[i];
                            soluong++;
                        }
                    }
                    dtgvKH.DataSource = hienthitheoid;
                }
                // Theo ma san pham
                if (rdbtimkiem2.Checked == true)
                {
                    if (txttimkiem.Text.Length == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].MaHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            soluong++;
                        }
                    }
                    if (soluong == 0)
                    {
                        dtgvKH.DataSource = new Entities.HangHoa[0];
                        return;
                    }
                    Entities.HangHoa[] hienthitheoma = new Entities.HangHoa[soluong];
                    soluong = 0;
                    for (int i = 0; i < hienthi.Length; i++)
                    {
                        int kiemtra = hienthi[i].MaHangHoa.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                        if (kiemtra >= 0)
                        {
                            hienthitheoma[soluong] = hienthi[i];
                            soluong++;
                        }
                    }
                    dtgvKH.DataSource = hienthitheoma;
                }
            }
            finally
            {
                // Ban le
                if (this.isBanLe)
                {
                    fixBL();
                }
                // ban buon
                else if (this.isBanBuon)
                {
                    fixBB();
                }
                // truong hop khac
                else
                {
                    fix();
                }
            }
        }
Example #40
0
 public Entities.HangHoa[] SelectHangHoa_Theo_MaHangHoa(string mahanghoa)
 {
     Entities.HangHoa temp = new Entities.HangHoa(); temp.ThaoTac = "select_TheoMaHangHoa"; temp.MaHangHoa = mahanghoa.ToUpper();
     return sp_SelectHangHoasAll(temp);
 }
        void KiemTraHangHoaTrongKho()
        {
            Entities.HangHoa[] kh1;
            cl = new Server_Client.Client();
            this.client1 = cl.Connect(Luu.IP, Luu.Ports);
            Entities.HangHoa kh = new Entities.HangHoa();
            string makho = LayMaKho(this.cbxTukho.Text);
            kh = new Entities.HangHoa("SelectTheoKho", makho);
            clientstrem = cl.SerializeObj(this.client1, "HangHoa", kh);
            kh1 = new Entities.HangHoa[1];
            kh1 = (Entities.HangHoa[])cl.DeserializeHepper1(clientstrem, kh1);
            if (kh1 == null)
                kh1 = new Entities.HangHoa[0];

            if (kh1.Length > 0)
            {
                bool ktdata = false;
                int sl = kh1.Length;
                for (int i = 0; i < sl; i++)
                {
                    if (kh1[i].Deleted == false)
                        if (kh1[i].MaHangHoa == toolStrip_txtTracuu.Text)
                        {
                            toolStrip_txtTracuu.Text = kh1[i].MaHangHoa;
                            toolStrip_txtTen.Text = kh1[i].TenHangHoa;
                            toolStrip_txtSoluong.Focus();
                            ktdata = true;
                            break;
                        }
                }
                if (ktdata == false)
                {
                    toolStrip_txtTen.Text = "";
                    toolStrip_txtSoluong.Text = "1";
                    this.khongcohanghoatrongkho = true;
                }
            }
            else
            {
                toolStrip_txtTen.Text = "";
                toolStrip_txtSoluong.Text = "1";
                this.khongcohanghoatrongkho = true;
            }
        }
Example #42
0
 private void tssSua_Click(object sender, EventArgs e)
 {
     if (KiemTra() == true)
     {
         Server_Client.Client client = new Server_Client.Client();
         this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
         Entities.HangHoa hh = new Entities.HangHoa();
         hh = new Entities.HangHoa("Update", int.Parse(txtHangHoaID.Text), txtMaHangHoa.Text, txtMaNhomHang.Text, txtTenHangHoa.Text, cmbMaNhaSanXuat.Text, txtMaVachNSX.Text, cmbMaDonViTinh.Text, float.Parse(txtGiaNhap.Text), float.Parse(txtGiaBanBuon.Text), float.Parse(txtGiaBanLe.Text), cmbMathueNhapKhau.Text, cmbMaThueXuatKhau.Text, cmbMaThueTieuThuDacBiet.Text, cmbMaThueGTGT.Text, txtKieuHangHoa.Text, txtSeri.Text, int.Parse(txtMucDatHang.Text), int.Parse(txtMucTonToiThieu.Text), txtChiTietThem.Text, txtNgungTheoDoi.Text, txtGhiChu.Text, false);
         networkStream = client.SerializeObj(this.tcpClient, "HangHoa", hh);
         bool kt = false;
         kt = (bool)client.DeserializeHepper(networkStream, kt);
         if (kt == true)
         {
             MessageBox.Show("Thành công");
         }
         this.Close();
     }
 }
Example #43
0
 public Entities.HangHoa[] HangHoaTheoKho(string makho)
 {
     Entities.HangHoa[] hanghoa = new BizLogic.HangHoa().SelectHHTheoKho(makho);
     if (hanghoa == null)
         hanghoa = new Entities.HangHoa[0];
     return hanghoa;
 }
        public void SelectData()
        {
            try
            {
                dgvHangHoa.RowHeadersVisible = false;
                cl             = new Server_Client.Client();
                this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                Entities.HangHoa hh = new Entities.HangHoa("Select");
                networkStream = cl.SerializeObj(this.tcpClient, "HangHoa", hh);
                Entities.HangHoa[] hh1 = new Entities.HangHoa[1];
                hh1 = (Entities.HangHoa[])cl.DeserializeHepper1(networkStream, hh1);

                // goi hang
                cl             = new Server_Client.Client();
                this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                Entities.CheckRefer ctxh = new Entities.CheckRefer("GH");
                networkStream = cl.SerializeObj(this.tcpClient, "Select", ctxh);
                Entities.GoiHang[] goihang = new Entities.GoiHang[0];
                goihang = (Entities.GoiHang[])cl.DeserializeHepper1(networkStream, goihang);



                if (hh1 == null && goihang == null)
                {
                    dgvHangHoa.DataSource = new Entities.HangHoa[0];
                    return;
                }

                List <Entities.HangHoa> listHangHoa = new List <Entities.HangHoa>();

                // for hang hoa
                foreach (Entities.HangHoa hanghoa in hh1)
                {
                    if (hanghoa != null && hanghoa.Deleted == false && hanghoa.MaNhomHangHoa.Equals(manhomhang))
                    {
                        listHangHoa.Add(hanghoa);
                    }
                }

                // for goi hang
                foreach (Entities.GoiHang gh in goihang)
                {
                    if (gh != null && gh.Deleted == false && gh.MaNhomHang.Equals(manhomhang))
                    {
                        Entities.HangHoa hanghoa = new Entities.HangHoa();
                        hanghoa.MaHangHoa     = gh.MaGoiHang;
                        hanghoa.TenHangHoa    = gh.TenGoiHang;
                        hanghoa.MaNhomHangHoa = gh.MaNhomHang;
                        hanghoa.GiaNhap       = gh.GiaNhap;
                        hanghoa.GiaBanBuon    = gh.GiaBanBuon;
                        hanghoa.GiaBanLe      = gh.GiaBanLe;
                        listHangHoa.Add(hanghoa);
                    }
                }
                dgvHangHoa.DataSource       = (Entities.HangHoa[])listHangHoa.ToArray();
                dgvHangHoa.Rows[0].Selected = true;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                fix1();
            }
        }