Exemplo n.º 1
0
        /// <summary>
        /// xử lý giá trị truyền tới
        /// </summary>
        /// <param name="str"></param>
        public frmXuLyBanLe(string str)
        {
            try
            {
                InitializeComponent();
                //
                cl = new Server_Client.Client();
                // gán TCPclient
                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
                CapNhatGia pt = new CapNhatGia("Select");
                // khởi tạo mảng đối tượng để hứng giá trị
                _cngkh = new CapNhatGia[1];
                Clientstrem = cl.SerializeObj(Client1, "CapNhatGia", pt);
                // đổ mảng đối tượng vào datagripview
                _cngkh = (CapNhatGia[])cl.DeserializeHepper1(Clientstrem, _cngkh) ?? new CapNhatGia[0];
                //
                _datesv = DateServer.Date();
                toolStripStatusLabel3.Enabled = false;
                dtgvsanpham.DataSource = new HangHoaHienThi[0];
                _str = str;
                TheVip();
                try
                {
                    LayKhoHang();
                    new Common.Utilities().ComboxKhoHang(cbbkhohang);
                }
                catch
                {
                }
                _datesv = DateServer.Date();
                cbxHinhthucthanhtoan.SelectedIndex = 0;
                mskngaychungtu.Text = new Common.Utilities().XuLy(2, _datesv.ToShortDateString());
                lbnhanvien.Text = Common.Utilities.User.TenNhanVien;
                //
                KhoiTao();
                _kmSoLuong = GetData();
            }
            catch
            {

            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// kiểm tra chiết khấu
 /// </summary>
 /// <param name="cnhkh"></param>
 public void KiemTraCk(CapNhatGia[] cnhkh)
 {
     try
     {
         foreach (CapNhatGia capNhatGia in cnhkh.Where(capNhatGia => capNhatGia.MaHangHoa == mahanghoa).Where(capNhatGia => _datesv >= capNhatGia.NgayBatDau && _datesv <= capNhatGia.NgayKetThuc))
         {
             phantramchietkhau = tsslchietkhau.Text = capNhatGia.PhanTramGiaBanLe;
         }
         //foreach (CapNhatGia capNhatGia in cnhkh)
         //{
         //if (capNhatGia.MaHangHoa != mahanghoa) continue;
         //if (_datesv >= capNhatGia.NgayBatDau && _datesv <= capNhatGia.NgayKetThuc)
         //{
         //    phantramchietkhau = tsslchietkhau.Text = capNhatGia.PhanTramGiaBanLe;
         //}
         //}
     }
     catch
     {
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// select mã cập nhật khách hàng
 /// </summary>
 public void SelectMaCapNhatKh()
 {
     try
     {
         cl = new Server_Client.Client();
         // gán TCPclient
         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
         CapNhatGia pt = new CapNhatGia("Select");
         // khởi tạo mảng đối tượng để hứng giá trị
         _cngkh = new CapNhatGia[1];
         Clientstrem = cl.SerializeObj(Client1, "CapNhatGia", pt);
         // đổ mảng đối tượng vào datagripview
         _cngkh = (CapNhatGia[])cl.DeserializeHepper1(Clientstrem, _cngkh) ?? new CapNhatGia[0];
     }
     catch { }
 }
Exemplo n.º 4
0
        public void HienThiDgvChinhSachGiaKhuyenMai(string MaHangHoa)
        {
            client = new Server_Client.Client();
            this.tcpClient = client.Connect(Luu.IP, Luu.Ports);

            Entities.CapNhatGia nsx = new Entities.CapNhatGia();
            nsx = new Entities.CapNhatGia("Select");
            networkStream = client.SerializeObj(this.tcpClient, "CapNhatGia", nsx);
            Entities.CapNhatGia[] nsx1 = new Entities.CapNhatGia[1];
            nsx1 = (Entities.CapNhatGia[])client.DeserializeHepper1(networkStream, nsx1);
            if (nsx1 != null)
            {
                int count = 0;
                for (int i = 0; i < nsx1.Length; i++)
                {
                    if (nsx1[i].MaHangHoa == MaHangHoa)
                    {
                        count++;
                    }
                }
                if (count > 0)
                {
                    Entities.CapNhatGia[] cng1 = new Entities.CapNhatGia[count];

                    count = 0;
                    for (int i = 0; i < nsx1.Length; i++)
                    {
                        if (nsx1[i].MaHangHoa == MaHangHoa)
                        {
                            cng1[count] = new Entities.CapNhatGia();
                            cng1[count] = nsx1[i];
                            count++;
                        }
                    }
                    dgvChinhSachGiaKhuyenMai.DataSource = cng1;
                    FixDataGridView();
                }
            }
            else
            {
                //MessageBox.Show("Null");
            }
        }
Exemplo n.º 5
0
 public void CheckConflictInsertCapNhatGia()
 {
     try
     {
         Server_Client.Client cl = new Server_Client.Client();
         this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
         Entities.CapNhatGia pt = new Entities.CapNhatGia("Select");
         Entities.CapNhatGia[] pt1 = new Entities.CapNhatGia[1];
         networkStream = cl.SerializeObj(this.tcpClient, "CapNhatGia", pt);
         pt1 = (Entities.CapNhatGia[])cl.DeserializeHepper1(networkStream, pt1);
         if (pt1 != null)
         {
             for (int j = 0; j < pt1.Length; j++)
             {
                 if (pt1[j].MaCapNhatGia == txtMaCapNhat.Text)
                 {
                     MessageBox.Show("Lỗi Rồi");
                     kt1 = "ko";
                     txtMaCapNhat.Text = LayID("CapNhatGia");
                     break;
                 }
                 else
                     kt1 = "ok";
             }
         }
         else
             kt1 = "ok";
     }
     catch
     {
     }
 }
Exemplo n.º 6
0
        //Cập Nhật Giá
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (Validate())
            {
                CheckConflictInsertCapNhatGia();
                if (kt1 == "ok")
                {
                    double bb, bl, gn;

                    if (txtPhanTramBB.Text == "")
                    {
                        bb = 0;
                    }
                    else
                        bb = double.Parse(txtPhanTramBB.Text);
                    if (txtPhanTramBL.Text == "")
                    {
                        bl = 0;
                    }
                    else
                        bl = double.Parse(txtPhanTramBL.Text);
                    if (txtGN.Text == "")
                    {
                        gn = 0;
                    }
                    else
                        gn = double.Parse(txtGN.Text);

                    Server_Client.Client cl = new Server_Client.Client();
                    // gán TCPclient
                    this.tcpClient = cl.Connect(Luu.IP, Luu.Ports);
                    Entities.CapNhatGia nv = new Entities.CapNhatGia("Insert", 1, txtMaCapNhat.Text,
                        ConvertDatetime(makNgayBatDau.Text), ConvertDatetime(makNgayKetThuc.Text), txtMaHangHoa.Text, bb.ToString(), bl.ToString(), gn.ToString(), true, "", false);
                    networkStream = cl.SerializeObj(this.tcpClient, "CapNhatGia", nv);
                    int msg = 0;
                    msg = (int)cl.DeserializeHepper(networkStream, msg);
                    if (msg == 1)
                    {
                        txtMaCapNhat.Text = LayID("CapNhatGia");
                        makNgayBatDau.Text = "";
                        makNgayKetThuc.Text = "";
                        txtGN.Text = "";
                        txtPhanTramBB.Text = "";
                        txtPhanTramBL.Text = "";
                        HienThiDgvChinhSachGiaKhuyenMai(txtMaHangHoa.Text);
                    }
                    else
                        MessageBox.Show("Insert that bai");
                }
            }
        }