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

            Entities.LoaiHangHoa lhh = new Entities.LoaiHangHoa("Select");
            Entities.LoaiHangHoa[] lhh1 = new Entities.LoaiHangHoa[1];
            networkStream = client.SerializeObj(this.tcpClient, "NhanVien", lhh);

            lhh1 = (Entities.LoaiHangHoa[])client.DeserializeHepper1(networkStream, lhh1);
            if (lhh1 != null)
            {
                for (int j = 0; j < lhh1.Length; j++)
                {
                    if (lhh1[j].MaLoaiHang == txtTenLoaiHang.Text)
                    {
                        MessageBox.Show("Thất bại");
                        chck = "No";
                        txtTenLoaiHang.Text = new Common.Utilities().ProcessID(txtTenLoaiHang.Text);
                        break;
                    }
                    else
                        chck = "Yes";
                }
            }
        }
Exemplo n.º 2
0
        //Xóa Data trên Data Grid View
        #region Xử lý khi Delete
        private void tssXoa_Click(object sender, EventArgs e)
        {
            string maKH = dgvQuanLyLoaiHangHoa.Rows[i].Cells["MaLoaiHang"].Value.ToString();

            if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 3))
            {
                MessageBox.Show("Bạn Không có quyền vào chức năng này.");
                return;
            }
            if (new Check().CheckReference("LoaiHangHoa", maKH))
            {
                DialogResult dlgResult = MessageBox.Show("Bạn Có Chắc Chắn muốn Xóa Loại Hàng Hóa này không?", "Đồng ý?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlgResult == DialogResult.Yes)
                {
                    try
                    {
                        bool ktdelete = false;
                        int  idcurent = int.Parse(dgvQuanLyLoaiHangHoa.Rows[i].Cells["LoaiHangID"].Value.ToString());
                        SelectData();
                        for (int j = 0; j < kh1.Length; j++)
                        {
                            if (kh1[j].Deleted == false)
                            {
                                if (kh1[j].LoaiHangID == idcurent)
                                {
                                    ktdelete = true;
                                    break;
                                }
                            }
                        }
                        if (ktdelete == true)
                        {
                            cl           = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                            Entities.LoaiHangHoa kh = new Entities.LoaiHangHoa();
                            kh            = new Entities.LoaiHangHoa("Delete", idcurent, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                            networkStream = cl.SerializeObj(this.client1, "LoaiHangHoa", kh);
                            bool kt = false;
                            kt = (bool)cl.DeserializeHepper(networkStream, kt);
                            if (kt == true)
                            {
                            }
                        }
                        else
                        {
                            MessageBox.Show("Loại Hàng này đã bị xóa");
                        }
                        SelectData();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Loại hàng này không thể xóa! Hiện đang có giao dịch");
            }
        }
Exemplo n.º 3
0
 public void CheckConflictUpdate()
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         this.tcpClient = 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.LoaiHangHoa kh = new Entities.LoaiHangHoa("Select");
         // khởi tạo mảng đối tượng để hứng giá trị
         kh1           = new Entities.LoaiHangHoa[1];
         networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", kh);
         // đổ mảng đối tượng vào datagripview
         kh1 = (Entities.LoaiHangHoa[])cl.DeserializeHepper1(networkStream, kh1);
         if (kh1 != null)
         {
             for (int j = 0; j < kh1.Length; j++)
             {
                 if (kh1[j].MaLoaiHang == maloaihang)
                 {
                     kt = Check(kh1[j]);
                     break;
                 }
                 else
                 {
                     kt = "ok";
                 }
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 4
0
 //Sửa
 private void tssSua_Click(object sender, EventArgs e)
 {
     try
     {
         if (KiemTra())
         {
             CheckConflictUpdate();
             if (kt == "ok")
             {
                 Server_Client.Client cl = new Server_Client.Client();
                 this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                 Entities.LoaiHangHoa nv = new Entities.LoaiHangHoa();
                 nv            = new Entities.LoaiHangHoa("Update", int.Parse(id), txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                 networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", nv);
                 int msg = 0;
                 msg = (int)cl.DeserializeHepper(networkStream, msg);
                 if (msg == 1)
                 {
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Thất Bại");
                 }
             }
             else
             {
                 MessageBox.Show("Thay đổi dữ liệu");
             }
         }
     }
     catch { }
 }
Exemplo n.º 5
0
        private void tssThem_Click(object sender, EventArgs e)
        {
            try
            {
                if (KiemTra())
                {
                    CheckConflictInsert();
                    if (kt == "ok")
                    {
                        ktgiatri = "a";
                        Server_Client.Client cl = new Server_Client.Client();
                        this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                        Entities.LoaiHangHoa nv = new Entities.LoaiHangHoa();
                        nv            = new Entities.LoaiHangHoa("Insert", 0, txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                        networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", nv);
                        int msg = 0;
                        msg = (int)cl.DeserializeHepper(networkStream, msg);
                        if (msg == 1)
                        {
                            this.Close();
                        }

                        else
                        {
                            MessageBox.Show("mã loại hàng hóa đã thay đổi - kiểm tra lại dữ liệu");
                            txtMaLoaiHang.Text = new Common.Utilities().ProcessID(txtMaLoaiHang.Text);
                        }
                    }
                }
            }
            catch { }
        }
Exemplo n.º 6
0
        public void LayTenLoaiHang()
        {
            try
            {
                cmbLoaihang.Items.Clear();
                client         = new Server_Client.Client();
                this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

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

                if (nh1.Length > 0)
                {
                    int sl = nh1.Length;
                    for (int i = 0; i < sl; i++)
                    {
                        if (nh1[i].Deleted == false)
                        {
                            cmbLoaihang.Items.Add(nh1[i].TenLoaiHang);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 7
0
        public void checkConflict()
        {
            Server_Client.Client client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.LoaiHangHoa   lhh  = new Entities.LoaiHangHoa("Select");
            Entities.LoaiHangHoa[] lhh1 = new Entities.LoaiHangHoa[1];
            networkStream = client.SerializeObj(this.tcpClient, "NhanVien", lhh);

            lhh1 = (Entities.LoaiHangHoa[])client.DeserializeHepper1(networkStream, lhh1);
            if (lhh1 != null)
            {
                for (int j = 0; j < lhh1.Length; j++)
                {
                    if (lhh1[j].MaLoaiHang == txtTenLoaiHang.Text)
                    {
                        MessageBox.Show("Thất bại");
                        chck = "No";
                        txtTenLoaiHang.Text = new Common.Utilities().ProcessID(txtTenLoaiHang.Text);
                        break;
                    }
                    else
                    {
                        chck = "Yes";
                    }
                }
            }
        }
Exemplo n.º 8
0
        //Xử Lý Thêm
        #region Xử lý Thêm
        private void tssThem_Click(object sender, EventArgs e)
        {
            Server_Client.Client client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
            Entities.LoaiHangHoa nh = new Entities.LoaiHangHoa();
            nh            = new Entities.LoaiHangHoa("Insert", 0, txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false);
            networkStream = client.SerializeObj(this.tcpClient, "LoaiHangHoa", nh);
            bool kt = false;

            kt = (bool)client.DeserializeHepper(networkStream, kt);
            if (kt == true)
            {
                MessageBox.Show("Thành công");
            }
            this.Close();
        }
Exemplo n.º 9
0
 //Sửa
 #region Xử lý Khi Sửa
 private void tssSua_Click_1(object sender, EventArgs e)
 {
     if (KiemTra() == true)
     {
         Server_Client.Client client = new Server_Client.Client();
         this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
         Entities.LoaiHangHoa nh;
         nh            = new Entities.LoaiHangHoa("Update", int.Parse(dgvr1.Cells[1].Value.ToString()), txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false);
         networkStream = client.SerializeObj(this.tcpClient, "LoaiHangHoa", nh);
         bool kt = false;
         kt = (bool)client.DeserializeHepper(networkStream, kt);
         if (kt == true)
         {
             MessageBox.Show("Thành công");
         }
         this.Close();
     }
 }
Exemplo n.º 10
0
 //Check Thêm
 public void CheckConflictInsert()
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         this.tcpClient = 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.LoaiHangHoa ncc = new Entities.LoaiHangHoa("Select");
         // khởi tạo mảng đối tượng để hứng giá trị
         Entities.LoaiHangHoa[] ncc1 = new Entities.LoaiHangHoa[1];
         networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", ncc);
         // đổ mảng đối tượng vào datagripview
         ncc1 = (Entities.LoaiHangHoa[])cl.DeserializeHepper1(networkStream, ncc1);
         if (ncc1 != null)
         {
             for (int j = 0; j < ncc1.Length; j++)
             {
                 if (ncc1[j].MaLoaiHang == maloaihang)
                 {
                     MessageBox.Show("cập nhật mã loại hàng - kiểm tra lại để insert");
                     kt         = "ko";
                     maloaihang = txtMaLoaiHang.Text = ProID("LoaiHang");
                     break;
                 }
                 else
                 {
                     kt = "ok";
                 }
             }
         }
         else
         {
             kt = "ok";
         }
     }
     catch
     {
     }
 }
Exemplo n.º 11
0
        public string Check(Entities.LoaiHangHoa kh)
        {
            try
            {
                string gt = "ok";

                if (tenloaihang != kh.TenLoaiHang)
                {
                    tenloaihang = txtTenLoaiHang.Text = kh.TenLoaiHang;
                    gt          = "ko";
                }

                if (ghichu != kh.GhiChu)
                {
                    ghichu = txtGhiChu.Text = kh.GhiChu;
                    gt     = "ko";
                }
                return(gt);
            }
            finally
            { }
        }
Exemplo n.º 12
0
        //Lấy dữ liệu từ Database
        public void SelectData()
        {
            try
            {

                i = 0;
                dgvQuanLyLoaiHangHoa.RowHeadersVisible = false;
                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.LoaiHangHoa kh = new Entities.LoaiHangHoa();
                // truyền HanhDong
                kh = new Entities.LoaiHangHoa("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                kh1 = new Entities.LoaiHangHoa[1];
                networkStream = cl.SerializeObj(this.client1, "LoaiHangHoa", kh);
                // đổ mảng đối tượng vào datagripview
                kh1 = (Entities.LoaiHangHoa[])cl.DeserializeHepper1(networkStream, kh1);
                //lbhienthitongso.Text = kh1.Length.ToString();
                if (kh1 == null)
                {
                    tssXoa.Enabled = false;
                    hienthi = new Entities.LoaiHangHoa[0];
                    dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                    return;
                }
                tssXoa.Enabled = true;

                Entities.LoaiHangHoa[] pt2 = new Entities.LoaiHangHoa[kh1.Length];
                int sotang = 0;
                for (int j = 0; j < kh1.Length; j++)
                {

                    if (kh1[j].Deleted == false)
                    {
                        pt2[sotang] = kh1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.LoaiHangHoa[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = pt2[j];
                    }
                }
                else
                {
                    dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                    return;
                }
                dgvQuanLyLoaiHangHoa.DataSource = hienthi;
                new Common.Utilities().CountDatagridview(dgvQuanLyLoaiHangHoa);

                dgvQuanLyLoaiHangHoa.Rows[0].Selected = true;
            }
            finally
            {
                try
                {
                    for (int j = 1; j < dgvQuanLyLoaiHangHoa.ColumnCount; j++)
                    {
                        dgvQuanLyLoaiHangHoa.Columns[j].Visible = false;
                    }
                    new Common.Utilities().CountDatagridview(dgvQuanLyLoaiHangHoa);
                    dgvQuanLyLoaiHangHoa.Columns[0].Visible = true;
                    dgvQuanLyLoaiHangHoa.Columns[0].HeaderText = "STT";
                    dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].HeaderText = "Mã Loại Hàng";
                    dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].HeaderText = "Tên Loại Hàng";
                    dgvQuanLyLoaiHangHoa.Columns["GhiChu"].HeaderText = "Ghi Chú";
                    dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].Visible = true;
                    dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].Visible = true;
                    dgvQuanLyLoaiHangHoa.Columns["GhiChu"].Visible = true;
                    dgvQuanLyLoaiHangHoa.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                    dgvQuanLyLoaiHangHoa.AllowUserToAddRows = false;
                    dgvQuanLyLoaiHangHoa.AllowUserToDeleteRows = false;
                    dgvQuanLyLoaiHangHoa.AllowUserToResizeRows = false;
                }
                catch { }
            }
        }
Exemplo n.º 13
0
        //Lấy dữ liệu từ Database
        public void SelectData()
        {
            try
            {
                i = 0;
                dgvQuanLyLoaiHangHoa.RowHeadersVisible = false;
                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.LoaiHangHoa kh = new Entities.LoaiHangHoa();
                // truyền HanhDong
                kh = new Entities.LoaiHangHoa("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                kh1           = new Entities.LoaiHangHoa[1];
                networkStream = cl.SerializeObj(this.client1, "LoaiHangHoa", kh);
                // đổ mảng đối tượng vào datagripview
                kh1 = (Entities.LoaiHangHoa[])cl.DeserializeHepper1(networkStream, kh1);
                //lbhienthitongso.Text = kh1.Length.ToString();
                if (kh1 == null)
                {
                    tssXoa.Enabled = false;
                    hienthi        = new Entities.LoaiHangHoa[0];
                    dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                    return;
                }
                tssXoa.Enabled = true;

                Entities.LoaiHangHoa[] pt2 = new Entities.LoaiHangHoa[kh1.Length];
                int sotang = 0;
                for (int j = 0; j < kh1.Length; j++)
                {
                    if (kh1[j].Deleted == false)
                    {
                        pt2[sotang] = kh1[j];
                        sotang++;
                    }
                }
                hienthi = new Entities.LoaiHangHoa[sotang];
                if (sotang != 0)
                {
                    for (int j = 0; j < sotang; j++)
                    {
                        hienthi[j] = pt2[j];
                    }
                }
                else
                {
                    dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                    return;
                }
                dgvQuanLyLoaiHangHoa.DataSource = hienthi;
                new Common.Utilities().CountDatagridview(dgvQuanLyLoaiHangHoa);

                dgvQuanLyLoaiHangHoa.Rows[0].Selected = true;
            }
            finally
            {
                try
                {
                    for (int j = 1; j < dgvQuanLyLoaiHangHoa.ColumnCount; j++)
                    {
                        dgvQuanLyLoaiHangHoa.Columns[j].Visible = false;
                    }
                    new Common.Utilities().CountDatagridview(dgvQuanLyLoaiHangHoa);
                    dgvQuanLyLoaiHangHoa.Columns[0].Visible                = true;
                    dgvQuanLyLoaiHangHoa.Columns[0].HeaderText             = "STT";
                    dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].HeaderText  = "Mã Loại Hàng";
                    dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].HeaderText = "Tên Loại Hàng";
                    dgvQuanLyLoaiHangHoa.Columns["GhiChu"].HeaderText      = "Ghi Chú";
                    dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].Visible     = true;
                    dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].Visible    = true;
                    dgvQuanLyLoaiHangHoa.Columns["GhiChu"].Visible         = true;
                    dgvQuanLyLoaiHangHoa.AutoSizeColumnsMode               = DataGridViewAutoSizeColumnsMode.Fill;
                    dgvQuanLyLoaiHangHoa.AllowUserToAddRows                = false;
                    dgvQuanLyLoaiHangHoa.AllowUserToDeleteRows             = false;
                    dgvQuanLyLoaiHangHoa.AllowUserToResizeRows             = false;
                }
                catch { }
            }
        }
Exemplo n.º 14
0
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtatca.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
             return;
         }
         int soluong = 0;
         if (hienthi != null)
         {
             if (rdbtheoma.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].TenLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                     return;
                 }
                 Entities.LoaiHangHoa[] hienthitheoid = new Entities.LoaiHangHoa[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].TenLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoid[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dgvQuanLyLoaiHangHoa.DataSource = hienthitheoid;
             }
             if (rdbtheoten.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                     return;
                 }
                 Entities.LoaiHangHoa[] hienthitheoma = new Entities.LoaiHangHoa[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoma[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dgvQuanLyLoaiHangHoa.DataSource = hienthitheoma;
             }
         }
     }
     finally
     {
         try
         {
             for (int j = 1; j < dgvQuanLyLoaiHangHoa.ColumnCount; j++)
             {
                 dgvQuanLyLoaiHangHoa.Columns[j].Visible = false;
             }
             new Common.Utilities().CountDatagridview(dgvQuanLyLoaiHangHoa);
             dgvQuanLyLoaiHangHoa.Columns[0].Visible                = true;
             dgvQuanLyLoaiHangHoa.Columns[0].HeaderText             = "STT";
             dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].HeaderText  = "Mã Loại Hàng";
             dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].HeaderText = "Tên Loại Hàng";
             dgvQuanLyLoaiHangHoa.Columns["GhiChu"].HeaderText      = "Ghi Chú";
             dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].Visible     = true;
             dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].Visible    = true;
             dgvQuanLyLoaiHangHoa.Columns["GhiChu"].Visible         = true;
             dgvQuanLyLoaiHangHoa.AutoSizeColumnsMode               = DataGridViewAutoSizeColumnsMode.Fill;
             dgvQuanLyLoaiHangHoa.AllowUserToAddRows                = false;
             dgvQuanLyLoaiHangHoa.AllowUserToDeleteRows             = false;
             dgvQuanLyLoaiHangHoa.AllowUserToResizeRows             = false;
         }
         catch { }
     }
 }
Exemplo n.º 15
0
        //Lấy Mã Nhóm Hàng Hóa
        public void LayLoaiHangHoa()
        {
            cbbLoaiHangHoa.Items.Clear();
            client = new Server_Client.Client();
            this.client1 = client.Connect(Luu.IP, Luu.Ports);

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

            cbbLoaiHangHoa.DataSource = nh1;
            cbbLoaiHangHoa.DisplayMember = "TenLoaiHang";
        }
Exemplo n.º 16
0
        private void tssThem_Click(object sender, EventArgs e)
        {
            try
            {
                if (KiemTra())
                {
                    CheckConflictInsert();
                    if (kt == "ok")
                    {

                        ktgiatri = "a";
                        Server_Client.Client cl = new Server_Client.Client();
                        this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                        Entities.LoaiHangHoa nv = new Entities.LoaiHangHoa();
                        nv = new Entities.LoaiHangHoa("Insert", 0, txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                        networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", nv);
                        int msg = 0;
                        msg = (int)cl.DeserializeHepper(networkStream, msg);
                        if (msg == 1)
                        {
                            this.Close();
                        }

                        else
                        {
                            MessageBox.Show("mã loại hàng hóa đã thay đổi - kiểm tra lại dữ liệu");
                            txtMaLoaiHang.Text = new Common.Utilities().ProcessID(txtMaLoaiHang.Text);
                        }

                    }

                }
            }
            catch { }
        }
Exemplo n.º 17
0
        public void CheckConflictUpdate()
        {
            try
            {
                cl = new Server_Client.Client();
                // gán TCPclient
                this.tcpClient = 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.LoaiHangHoa kh = new Entities.LoaiHangHoa("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                kh1 = new Entities.LoaiHangHoa[1];
                networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", kh);
                // đổ mảng đối tượng vào datagripview
                kh1 = (Entities.LoaiHangHoa[])cl.DeserializeHepper1(networkStream, kh1);
                if (kh1 != null)
                {
                    for (int j = 0; j < kh1.Length; j++)
                    {
                        if (kh1[j].MaLoaiHang == maloaihang)
                        {

                            kt = Check(kh1[j]);
                            break;
                        }
                        else
                            kt = "ok";
                    }

                }

            }
            catch
            {
            }
        }
Exemplo n.º 18
0
 private void tssSua_Click_1(object sender, EventArgs e)
 {
     if (KiemTra() == true)
     {
         Server_Client.Client client = new Server_Client.Client();
         this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
         Entities.LoaiHangHoa nh ;
         nh = new Entities.LoaiHangHoa("Update", int.Parse(dgvr1.Cells[1].Value.ToString()) , txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false);
         networkStream = client.SerializeObj(this.tcpClient, "LoaiHangHoa", nh);
         bool kt = false;
         kt = (bool)client.DeserializeHepper(networkStream, kt);
         if (kt == true)
         {
             MessageBox.Show("Thành công");
         }
         this.Close();
     }
 }
Exemplo n.º 19
0
        public void LayTenLoaiHang()
        {
            try
            {
                cmbLoaihang.Items.Clear();
                client = new Server_Client.Client();
                this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

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

                if (nh1.Length > 0)
                {
                    int sl = nh1.Length;
                    for (int i = 0; i < sl; i++)
                    {
                        if (nh1[i].Deleted == false)
                            cmbLoaihang.Items.Add(nh1[i].TenLoaiHang);
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 20
0
        private void tssXoa_Click(object sender, EventArgs e)
        {
            string maKH = dgvQuanLyLoaiHangHoa.Rows[i].Cells["MaLoaiHang"].Value.ToString();

            if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 3))
            {
                MessageBox.Show("Bạn Không có quyền vào chức năng này.");
                return;
            }
            if (new Check().CheckReference("LoaiHangHoa", maKH))
            {
                DialogResult dlgResult = MessageBox.Show("Bạn Có Chắc Chắn muốn Xóa Loại Hàng Hóa này không?", "Đồng ý?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dlgResult == DialogResult.Yes)
                {
                    try
                    {
                        bool ktdelete = false;
                        int idcurent = int.Parse(dgvQuanLyLoaiHangHoa.Rows[i].Cells["LoaiHangID"].Value.ToString());
                        SelectData();
                        for (int j = 0; j < kh1.Length; j++)
                        {
                            if (kh1[j].Deleted == false)
                                if (kh1[j].LoaiHangID == idcurent)
                                {
                                    ktdelete = true;
                                    break;
                                }
                        }
                        if (ktdelete == true)
                        {
                            cl = new Server_Client.Client();
                            this.client1 = cl.Connect(Luu.IP, Luu.Ports);

                            Entities.LoaiHangHoa kh = new Entities.LoaiHangHoa();
                            kh = new Entities.LoaiHangHoa("Delete", idcurent, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                            networkStream = cl.SerializeObj(this.client1, "LoaiHangHoa", kh);
                            bool kt = false;
                            kt = (bool)cl.DeserializeHepper(networkStream, kt);
                            if (kt == true)
                            {
                            }
                        }
                        else
                        {
                            MessageBox.Show("Loại Hàng này đã bị xóa");
                        }
                        SelectData();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Loại hàng này không thể xóa! Hiện đang có giao dịch");
            }
        }
Exemplo n.º 21
0
 //Sửa
 private void tssSua_Click(object sender, EventArgs e)
 {
     try
     {
         if (KiemTra())
         {
             CheckConflictUpdate();
             if (kt == "ok")
             {
                 Server_Client.Client cl = new Server_Client.Client();
                 this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                 Entities.LoaiHangHoa nv = new Entities.LoaiHangHoa();
                 nv = new Entities.LoaiHangHoa("Update", int.Parse(id), txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false, Common.Utilities.User.NhanVienID, Common.Utilities.User.TenDangNhap);
                 networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", nv);
                 int msg = 0;
                 msg = (int)cl.DeserializeHepper(networkStream, msg);
                 if (msg == 1)
                 {
                     this.Close();
                 }
                 else
                     MessageBox.Show("Thất Bại");
             }
             else
             {
                 MessageBox.Show("Thay đổi dữ liệu");
             }
         }
     }
     catch { }
 }
Exemplo n.º 22
0
 private void txttimkiem_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (rdbtatca.Checked == true)
         {
             return;
         }
         if (txttimkiem.Text.Length == 0)
         {
             dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
             return;
         }
         int soluong = 0;
         if (hienthi != null)
         {
             if (rdbtheoma.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].TenLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                     return;
                 }
                 Entities.LoaiHangHoa[] hienthitheoid = new Entities.LoaiHangHoa[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].TenLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoid[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dgvQuanLyLoaiHangHoa.DataSource = hienthitheoid;
             }
             if (rdbtheoten.Checked == true)
             {
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         soluong++;
                     }
                 }
                 if (soluong == 0)
                 {
                     dgvQuanLyLoaiHangHoa.DataSource = new Entities.LoaiHangHoa[0];
                     return;
                 }
                 Entities.LoaiHangHoa[] hienthitheoma = new Entities.LoaiHangHoa[soluong];
                 soluong = 0;
                 for (int i = 0; i < hienthi.Length; i++)
                 {
                     int kiemtra = hienthi[i].MaLoaiHang.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper());
                     if (kiemtra >= 0)
                     {
                         hienthitheoma[soluong] = hienthi[i];
                         soluong++;
                     }
                 }
                 dgvQuanLyLoaiHangHoa.DataSource = hienthitheoma;
             }
         }
     }
     finally
     {
         try
         {
             for (int j = 1; j < dgvQuanLyLoaiHangHoa.ColumnCount; j++)
             {
                 dgvQuanLyLoaiHangHoa.Columns[j].Visible = false;
             }
             new Common.Utilities().CountDatagridview(dgvQuanLyLoaiHangHoa);
             dgvQuanLyLoaiHangHoa.Columns[0].Visible = true;
             dgvQuanLyLoaiHangHoa.Columns[0].HeaderText = "STT";
             dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].HeaderText = "Mã Loại Hàng";
             dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].HeaderText = "Tên Loại Hàng";
             dgvQuanLyLoaiHangHoa.Columns["GhiChu"].HeaderText = "Ghi Chú";
             dgvQuanLyLoaiHangHoa.Columns["MaLoaiHang"].Visible = true;
             dgvQuanLyLoaiHangHoa.Columns["TenLoaiHang"].Visible = true;
             dgvQuanLyLoaiHangHoa.Columns["GhiChu"].Visible = true;
             dgvQuanLyLoaiHangHoa.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
             dgvQuanLyLoaiHangHoa.AllowUserToAddRows = false;
             dgvQuanLyLoaiHangHoa.AllowUserToDeleteRows = false;
             dgvQuanLyLoaiHangHoa.AllowUserToResizeRows = false;
         }
         catch { }
     }
 }
Exemplo n.º 23
0
        //Check Thêm
        public void CheckConflictInsert()
        {
            try
            {
                cl = new Server_Client.Client();
                // gán TCPclient
                this.tcpClient = 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.LoaiHangHoa ncc = new Entities.LoaiHangHoa("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                Entities.LoaiHangHoa[] ncc1 = new Entities.LoaiHangHoa[1];
                networkStream = cl.SerializeObj(this.tcpClient, "LoaiHangHoa", ncc);
                // đổ mảng đối tượng vào datagripview
                ncc1 = (Entities.LoaiHangHoa[])cl.DeserializeHepper1(networkStream, ncc1);
                if (ncc1 != null)
                {
                    for (int j = 0; j < ncc1.Length; j++)
                    {
                        if (ncc1[j].MaLoaiHang == maloaihang)
                        {
                            MessageBox.Show("cập nhật mã loại hàng - kiểm tra lại để insert");
                            kt = "ko";
                            maloaihang = txtMaLoaiHang.Text = ProID("LoaiHang");
                            break;
                        }
                        else
                            kt = "ok";
                    }

                }
                else
                    kt = "ok";

            }
            catch
            {
            }
        }
Exemplo n.º 24
0
 private void tssThem_Click(object sender, EventArgs e)
 {
     Server_Client.Client client = new Server_Client.Client();
     this.tcpClient = client.Connect(Luu.IP, Luu.Ports);
     Entities.LoaiHangHoa nh = new Entities.LoaiHangHoa();
     nh = new Entities.LoaiHangHoa("Insert", 0, txtMaLoaiHang.Text, txtTenLoaiHang.Text, txtGhiChu.Text, false);
     networkStream = client.SerializeObj(this.tcpClient, "LoaiHangHoa", nh);
     bool kt = false;
     kt = (bool)client.DeserializeHepper(networkStream, kt);
     if (kt == true)
     {
         MessageBox.Show("Thành công");
     }
     this.Close();
 }