Example #1
0
        private void frmXuLyBanLe_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.F9) return; //Sửa giá hàng hóa
            if (!frmDangNhap.User.Administrator && !frmChinh.CheckQuyen("frmQuanLyHangHoa", 1))
            {
                MessageBox.Show(" Không có quyền vào chức năng này.");
                return;
            }
            string maHangHoa = toolStrip_txtTracuu.Text.Trim().ToUpper();
            if (string.IsNullOrEmpty(maHangHoa) || maHangHoa.Equals("<F4 - Tra cứu>"))
            {
                MessageBox.Show("Vui lòng chọn hàng hóa cần sửa giá!\r\n tại ô nhập mã hàng hóa, vui lòng điền thông tin mã hàng hoặc ấn F4 để tìm kiếm hàng hóa");
                toolStrip_txtTracuu.Focus(); return;
            }
            HangHoa[] tempReturn;
            bool kq = Utils.GetDataFromServer("HangHoa", new HangHoa { HanhDong = "SelectHangHoa_Theo_MaHangHoa", MaHangHoa = maHangHoa }, out tempReturn);
            if (!kq && tempReturn.Length == 0) return;
            frmXuLyHangHoa frm = new frmXuLyHangHoa("Update", tempReturn[0]);
            frm.ShowDialog();
            kq = Utils.GetDataFromServer("HangHoa", new HangHoa { HanhDong = "SelectHangHoa_Theo_MaHangHoa", MaHangHoa = maHangHoa }, out tempReturn);
            if (!kq && tempReturn.Length == 0) return;
            //Sửa xong thì cập nhật lại vào danh sách hàng hóa trong kho
            foreach (HangHoa hangHoa in _hangHoaTheoKho.Where(hangHoa => hangHoa.MaHangHoa.Equals(tempReturn[0].MaHangHoa)))
                Utils.Copy(tempReturn[0], hangHoa);

            HangHoa hangHoaTemp = GetGoodsByCode(maHangHoa);
            if (hangHoaTemp == null) return;
            try
            {
                mahanghoa = toolStrip_txtTracuu.Text = hangHoaTemp.MaHangHoa.ToUpper();
                tssltenhang.Text = hangHoaTemp.TenHangHoa;
                tsslgia.Text = new Common.Utilities().FormatMoney(double.Parse(hangHoaTemp.GiaBanLe));
                KiemTraCk(_cngkh);
                LayGiaTriThue(hangHoaTemp.MaThueGiaTriGiaTang);
                toolStrip_txtTracuu.ReadOnly = true;
                tsslsoluong.Focus();
            }
            catch { phantramchietkhau = tsslchietkhau.Text = "0"; }
        }
 private void tssThem_Click(object sender, EventArgs e)
 {
     KiemTra = "insert";
     if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 4))
     {
         MessageBox.Show("Bạn Không có quyền vào chức năng này.");
         return;
     }
     while (KiemTra == "insert")
     {
         frmXuLyHangHoa fr = new frmXuLyHangHoa("Insert", dgvQuanLyHangHoa.CurrentRow);
         fr.StartPosition = FormStartPosition.CenterScreen;
         fr.ShowDialog();
         SelectData();
     }
 }
 //Hiển thị Form Sửa Hàng Hóa khi Click
 private void dgvHangHoa_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (i < 0)
         return;
     try
     {
         frmXuLyHangHoa snhh = new frmXuLyHangHoa("Update", dgvHangHoa.Rows[i]);
         snhh.ShowDialog();
         SelectData();
         fix1();
     }
     catch
     {
     }
 }
 private void dgvQuanLyHangHoa_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 2))
         {
             MessageBox.Show("Bạn Không có quyền vào chức năng này.");
             return;
         }
         frmXuLyHangHoa shh = new frmXuLyHangHoa("Update", dgvQuanLyHangHoa.CurrentRow);
         shh.StartPosition = FormStartPosition.CenterScreen;
         shh.ShowDialog();
         SelectData();
         fix();
     }
 }
 private void tssSua_Click(object sender, EventArgs e)
 {
     if (!frmDangNhap.User.Administrator && !CheckQuyen(this.Name, 2))
     {
         MessageBox.Show("Bạn Không có quyền vào chức năng này.");
         return;
     }
     frmXuLyHangHoa fr = new frmXuLyHangHoa("Update", dgvQuanLyHangHoa.CurrentRow);
     fr.StartPosition = FormStartPosition.CenterScreen;
     fr.ShowDialog();
     SelectData();
     fix();
 }
 /// <summary>
 /// tim chi tiet hang hoa theo ma
 /// </summary>
 /// <param name="MaHang"></param>
 private void LayHangHoaTheoMa(string MaHang)
 {
     try
     {
         Entities.HienThi_ChiTiet_DonDatHang ktm = new Entities.HienThi_ChiTiet_DonDatHang();
         cl = new Server_Client.Client();
         this.client = cl.Connect(Luu.IP, Luu.Ports);
         ktm = new Entities.HienThi_ChiTiet_DonDatHang("Select", MaHang);
         clientstrem = cl.SerializeObj(this.client, "LayHangHoaTheoMaHangHoa", ktm);
         Entities.HienThi_ChiTiet_DonDatHang tra = new Entities.HienThi_ChiTiet_DonDatHang();
         tra = (Entities.HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra);
         if (tra.MaHangHoa == null || tra == null)
         {
             toolStrip_txtTracuu.Focus();
             frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", toolStrip_txtTracuu.Text);
             frm.ShowDialog();
             ResetTool();
             toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa;
         }
         else
         {
             toolStrip_txtTracuu.Text = tra.MaHangHoa;
             toolStrip_txtTenhang.Text = tra.TenHangHoa;
             toolStrip_txtSoluong.Text = tra.SoLuongDat.ToString();
             toolStrip_txtGiagoc.Text = tra.GiaGoc;
             banbuon = tra.Giabanbuon;
             banle = tra.Giabanle;
             giatrigiatang = tra.Thuegiatrigiatang;
             toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau;
             //toolStrip_txtSoluong.Text = "";
             toolStrip_txtSoluong.Focus();
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
 }
Example #7
0
        private void toolStrip_txtTracuu_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (hanhdong != "Insert") return;
                if (chekChonLoai.Checked) return;
                if (!testCharacter(toolStrip_txtTracuu.Text)) return;

                if (e.KeyCode == Keys.Enter)
                {
                    if (toolStrip_txtTracuu.Text != "" && toolStrip_txtTracuu.Text != "<F4 - Tra cứu>")
                    {
                        LayHangHoaTheoMa(toolStrip_txtTracuu.Text);
                    }
                    if (string.IsNullOrEmpty(toolStrip_txtTenhang.Text) && toolStrip_txtTracuu.Text != "<F4 - Tra cứu>")
                    {
                        toolStrip_txtTracuu.Focus();
                        frmXuLyHangHoa fr = new frmXuLyHangHoa("Insert");
                        fr.StartPosition = FormStartPosition.CenterScreen;
                        fr.ShowDialog();
                    }
                }
                if (e.KeyCode == Keys.F6)
                {
                    if (dgvInsertOrder.RowCount > 0)
                    {
                        this.dgvInsertOrder.Focus();
                        dgvInsertOrder.CurrentRow.Selected = true;
                    }
                    else
                    { MessageBox.Show("Không có hàng để sửa"); toolStrip_txtTracuu.Focus(); }
                }
                if (e.KeyCode == Keys.F3)
                {
                    txtThanhtoanngay.Focus();
                }
            }
            catch { }
        }
Example #8
0
 private HangHoa LayHangHoaTheoMa(HangHoa input)
 {
     try
     {
         string maHang = input.MaHangHoa;
         QuyDoiDonViTinh lDvtSelect;
         if (CheckQuyDoiDonViTinh(maHang, out lDvtSelect))
         {
             return new HangHoa();
             //tạm bỏ
             #region có quy đổi
             Entities.HienThi_ChiTiet_DonDatHang ktm = new Entities.HienThi_ChiTiet_DonDatHang();
             cl = new Server_Client.Client();
             this.client = cl.Connect(Luu.IP, Luu.Ports);
             ktm = new Entities.HienThi_ChiTiet_DonDatHang("Select", lDvtSelect.MaHangDuocQuyDoi);
             clientstrem = cl.SerializeObj(this.client, "LayHangHoaTheoMaHangHoa", ktm);
             Entities.HienThi_ChiTiet_DonDatHang tra = new Entities.HienThi_ChiTiet_DonDatHang();
             tra = (Entities.HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra);
             if (tra.MaHangHoa == null || tra == null)
             {
                 toolStrip_txtTracuu.Focus();
                 frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", lDvtSelect.MaHangDuocQuyDoi);
                 frm.ShowDialog();
                 ResetTool();
                 toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa;
                 //LayHangHoaTheoMa(toolStrip_txtTracuu.Text);
             }
             else
             {
                 toolStrip_txtTracuu.Text = lDvtSelect.MaHangQuyDoi;
                 if (lDvtSelect.TenHangDuocQuyDoi.Equals(""))
                 {
                     toolStrip_txtTenhang.Text = lDvtSelect.MaHangQuyDoi;
                 }
                 else
                 {
                     toolStrip_txtTenhang.Text = lDvtSelect.TenHangDuocQuyDoi;
                 }
                 if (tra.SoLuongDat != null && tra.SoLuongDat > 0)
                 {
                     if (lDvtSelect.SoLuongDuocQuyDoi != null || lDvtSelect.SoLuongDuocQuyDoi > 0)
                     {
                         try
                         {
                             toolStrip_txtSoluong.Text = (tra.SoLuongDat / lDvtSelect.SoLuongDuocQuyDoi).ToString();
                         }
                         catch { }
                     }
                 }
                 ////toolStrip_txtSoluong.Text = tra.SoLuongDat.ToString();
                 toolStrip_txtGiagoc.Text = tra.GiaGoc;
                 banbuon = tra.Giabanbuon;
                 banle = tra.Giabanle;
                 giatrigiatang = tra.Thuegiatrigiatang;
                 toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau;
                 toolStrip_txtThuegiatrigiatang.Text = int.Parse(0 + tra.Thuegiatrigiatang).ToString();
                 toolStrip_txtGianhap.Text = tra.GiaNhap;
                 toolStrip_txtNgayhethan.Text = this.Date.ToString("dd/MM/yyyy");
                 toolStrip_txtSoluong.Text = "";
                 toolStrip_txtSoluong.Focus();
             }
             #endregion
         }
         else
         {
             #region không có quy đổi
             cl = new Server_Client.Client();
             client = cl.Connect(Luu.IP, Luu.Ports);
             HangHoa temp = new HangHoa { HanhDong = "SelectHangHoa_Theo_MaHangHoa", MaHangHoa = maHang };
             clientstrem = cl.SerializeObj(client, "HangHoa", temp);
             HangHoa[] hh1 = new HangHoa[1];
             hh1 = (HangHoa[])cl.DeserializeHepper1(clientstrem, hh1);
             if (hh1 == null || hh1.Length == 0) return new HangHoa();
             return hh1[0];
             #endregion
         }
     }
     catch { }
     return new Entities.HangHoa();
 }
Example #9
0
 /// <summary>
 /// Tìm chi tiết hàng hóa và fill dữ liệu vào form
 /// </summary>
 /// <param name="maHang"></param>
 private void LayHangHoaTheoMa(string maHang)
 {
     try
     {
         QuyDoiDonViTinh lDvtSelect;
         if (CheckQuyDoiDonViTinh(maHang, out lDvtSelect))
         {
             #region có quy đổi
             HienThi_ChiTiet_DonDatHang ktm = new HienThi_ChiTiet_DonDatHang();
             cl = new Server_Client.Client();
             client = cl.Connect(Luu.IP, Luu.Ports);
             ktm = new HienThi_ChiTiet_DonDatHang("Select", lDvtSelect.MaHangDuocQuyDoi);
             clientstrem = cl.SerializeObj(client, "LayHangHoaTheoMaHangHoa", ktm);
             HienThi_ChiTiet_DonDatHang tra = new HienThi_ChiTiet_DonDatHang();
             tra = (HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra);
             if (tra == null)
             {
                 toolStrip_txtTracuu.Focus();
                 frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", lDvtSelect.MaHangDuocQuyDoi);
                 frm.ShowDialog();
                 ResetTool();
                 toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa;
                 //LayHangHoaTheoMa(toolStrip_txtTracuu.Text);
             }
             else
             {
                 toolStrip_txtTracuu.Text = lDvtSelect.MaHangQuyDoi;
                 toolStrip_txtTenhang.Text = string.IsNullOrEmpty(lDvtSelect.TenHangDuocQuyDoi) ? lDvtSelect.MaHangQuyDoi : lDvtSelect.TenHangDuocQuyDoi;
                 toolStrip_txtSoluong.Text = tra.SoLuongDat > 0 && lDvtSelect.SoLuongDuocQuyDoi > 0 ? (tra.SoLuongDat / lDvtSelect.SoLuongDuocQuyDoi).ToString() : string.Empty;
                 toolStrip_txtGiagoc.Text = tra.GiaGoc;
                 banbuon = tra.Giabanbuon;
                 banle = tra.Giabanle;
                 giatrigiatang = tra.Thuegiatrigiatang;
                 toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau;
                 toolStrip_txtThuegiatrigiatang.Text = int.Parse(0 + tra.Thuegiatrigiatang).ToString();
                 toolStrip_txtGianhap.Text = tra.GiaNhap;
                 toolStrip_txtNgayhethan.Text = Date.ToString("dd/MM/yyyy");
                 toolStrip_txtSoluong.Text = "";
                 toolStrip_txtSoluong.Focus();
             }
             #endregion
         }
         else
         {
             #region không có quy đổi
             HienThi_ChiTiet_DonDatHang ktm = new Entities.HienThi_ChiTiet_DonDatHang();
             cl = new Server_Client.Client();
             client = cl.Connect(Luu.IP, Luu.Ports);
             ktm = new HienThi_ChiTiet_DonDatHang("Select", maHang);
             clientstrem = cl.SerializeObj(client, "LayHangHoaTheoMaHangHoa", ktm);
             HienThi_ChiTiet_DonDatHang tra = new HienThi_ChiTiet_DonDatHang();
             tra = (HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra);
             if (tra == null)
             {
                 toolStrip_txtTracuu.Focus();
                 frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", toolStrip_txtTracuu.Text);
                 frm.ShowDialog();
                 ResetTool();
                 toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa;
             }
             else
             {
                 toolStrip_txtTracuu.Text = tra.MaHangHoa;
                 toolStrip_txtTenhang.Text = tra.TenHangHoa;
                 toolStrip_txtSoluong.Text = tra.SoLuongDat.ToString();
                 toolStrip_txtGiagoc.Text = tra.GiaGoc;
                 banbuon = tra.Giabanbuon;
                 banle = tra.Giabanle;
                 giatrigiatang = tra.Thuegiatrigiatang;
                 toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau;
                 toolStrip_txtThuegiatrigiatang.Text = int.Parse(0 + tra.Thuegiatrigiatang).ToString();
                 toolStrip_txtGianhap.Text = tra.GiaNhap;
                 toolStrip_txtNgayhethan.Text = Date.ToString("dd/MM/yyyy");
                 toolStrip_txtSoluong.Text = "";
                 toolStrip_txtSoluong.Focus();
             }
             #endregion
         }
     }
     catch { }
 }
Example #10
0
 private void frmXuLyNhapKho_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F9)
     {//Sửa giá hàng hóa
         string maHangHoa = toolStrip_txtTracuu.Text.Trim().ToUpper();
         if (string.IsNullOrEmpty(maHangHoa) || maHangHoa.Equals("<F4 - Tra cứu>"))
         {
             MessageBox.Show("Vui lòng chọn hàng hóa cần sửa giá!\r\n tại ô nhập mã hàng hóa, vui lòng điền thông tin mã hàng hoặc ấn F4 để tìm kiếm hàng hóa");
             toolStrip_txtTracuu.Focus(); return;
         }
         HangHoa temp = new HangHoa { MaHangHoa = maHangHoa };
         HangHoa tempReturn = LayHangHoaTheoMa(temp);
         frmXuLyHangHoa frm = new frmXuLyHangHoa("Update", tempReturn);
         frm.ShowDialog();
         LayHangHoaTheoMa(maHangHoa);
     }
 }