Example #1
0
 private void txthsl_Leave(object sender, EventArgs e)
 {
     if (txthsl.Text.Trim() != "")
     {
         float a = 0;
         if (!float.TryParse(BUS_HDB.ConvertToFloatType(txthsl.Text), out a))
         {
             MessageBox.Show("Giá trị phải là số!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txthsl.Focus();
             return;
         }
         else
         {
             if (a < 0.1)
             {
                 MessageBox.Show("Giá trị hợp lệ phải >= 0.1!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txthsl.Focus();
                 return;
             }
             else
             {
                 txthsl.Text = BUS_HDB.FormatNumber(a.ToString());
                 txthsl_TextChanged(sender, e);
             }
         }
     }
 }
Example #2
0
 private void txtluongcb_Leave(object sender, EventArgs e)
 {
     if (txtluongcb.Text.Trim() != "")
     {
         Int64 a = 0;
         if (!Int64.TryParse(BUS_HDB.ConvertToFloatType(txtluongcb.Text), out a))
         {
             MessageBox.Show("Giá trị phải là số!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtluongcb.Focus();
         }
         else
         {
             if (a < 0)
             {
                 MessageBox.Show("Giá trị hợp lệ phải >= 0!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtluongcb.Focus();
                 return;
             }
             else
             {
                 if (a.ToString().Length < 7)
                 {
                     MessageBox.Show("Lương hợp lệ phải >= 1 000 000!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     txtluongcb.Focus();
                     return;
                 }
                 else
                 {
                     txtluongcb.Text = BUS_HDB.FormatNumber(a.ToString());
                     txtluongcb_TextChanged(sender, e);
                 }
             }
         }
     }
 }
Example #3
0
 private void txtDonGiaBanSi_Leave(object sender, EventArgs e)
 {
     if (txtdongiabansi.Text != "")
     {
         Int64 a = 0;
         if (!Int64.TryParse(BUS_HDB.ConvertToFloatType(txtdongiabansi.Text), out a))
         {
             MessageBox.Show("Giá trị phải là số!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtdongiabansi.Focus();
         }
         else
         {
             if (a < 0)
             {
                 MessageBox.Show("Giá trị hợp lệ phải >= 0 !", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtdongiabansi.Focus();
             }
             else
             {
                 if (txtDonGiaNhap.Text != "")
                 {
                     if (a <= Int64.Parse(BUS_HDB.ConvertToFloatType(txtDonGiaNhap.Text)))
                     {
                         MessageBox.Show("Đơn giá bán không được bé hơn hoặc bằng đơn giá nhập!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         txtdongiabansi.Focus();
                         return;
                     }
                     else
                     {
                         txtdongiabansi.Text = BUS_HDB.FormatNumber(a.ToString());
                     }
                 }
                 else
                 {
                     txtdongiabansi.Text = BUS_HDB.FormatNumber(a.ToString());
                 }
                 if (txtDonGiaBanLe.Text != "")
                 {
                     if (a >= Int64.Parse(BUS_HDB.ConvertToFloatType(txtDonGiaBanLe.Text)))
                     {
                         MessageBox.Show("Đơn giá bán sỉ không được lớn hơn hoặc bằng đơn giá bán lẻ!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         txtdongiabansi.Focus();
                         return;
                     }
                     else
                     {
                         txtdongiabansi.Text = BUS_HDB.FormatNumber(a.ToString());
                     }
                 }
                 else
                 {
                     txtdongiabansi.Text = BUS_HDB.FormatNumber(a.ToString());
                 }
             }
         }
     }
 }
Example #4
0
        private void DataGridView_Click(object sender, EventArgs e)
        {
            if (DGVSanPham.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (DGVSanPham.CurrentRow.Index == DGVSanPham.NewRowIndex)
            {
                MessageBox.Show("Hãy chọn dòng có thông tin!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            txtMaSanPham.Text   = DGVSanPham.CurrentRow.Cells["IdSP"].Value.ToString();
            txtTenSanPham.Text  = DGVSanPham.CurrentRow.Cells["TenSP"].Value.ToString();
            cbMaNCU.Text        = DGVSanPham.CurrentRow.Cells["IdNCU"].Value.ToString();
            dtpNgaySX.Text      = DGVSanPham.CurrentRow.Cells["NgaySX"].Value.ToString();
            dtpngayhh.Text      = DGVSanPham.CurrentRow.Cells["NgayHH"].Value.ToString();
            dtpngaynhap.Text    = DGVSanPham.CurrentRow.Cells["NgayNhap"].Value.ToString();
            txtDonGiaBanLe.Text = BUS_HDB.FormatNumber(DGVSanPham.CurrentRow.Cells["DonGiaBanLe"].Value.ToString());

            txtnhasx.Text = DGVSanPham.CurrentRow.Cells["NhaSX"].Value.ToString();

            txtSoLuongNhap.Text = BUS_HDB.FormatNumber(DGVSanPham.CurrentRow.Cells["SLNhap"].Value.ToString());

            txtDonGiaNhap.Text = BUS_HDB.FormatNumber(DGVSanPham.CurrentRow.Cells["DonGiaNhap"].Value.ToString());

            txtdongiabansi.Text = BUS_HDB.FormatNumber(DGVSanPham.CurrentRow.Cells["DonGiaBanSi"].Value.ToString());

            txtdonvi.Text          = DGVSanPham.CurrentRow.Cells["Donvi"].Value.ToString();
            txtdonvi.ForeColor     = Color.Black;
            txtgiamgia.Text        = DGVSanPham.CurrentRow.Cells["GiamGia"].Value.ToString();
            richtxtAnhSanPham.Text = DGVSanPham.CurrentRow.Cells["AnhSP"].Value.ToString();

            if (!File.Exists(richtxtAnhSanPham.Text) && !Directory.Exists(richtxtAnhSanPham.Text))
            {
                picAnh.Image = null;
                MessageBox.Show("Hình ảnh không tồn tại do file bị xóa hoặc dường dẫn không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenSanPham.Focus();
                return;
            }
            else
            {
                picAnh.Image = Image.FromFile(richtxtAnhSanPham.Text);
            }
        }
Example #5
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (kh.Rows.Count == 0)
            {
                MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtMaKhachHang.Text == "Mã khách hàng sẽ tự động thêm!")
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show("Xoá khách hàng sẽ xoá tất cả dữ liệu của khách hàng và tất cả các thông tin về hoá đơn có liên quan với khách hàng này. Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                List <string> idkh = new List <string>();

                DataTable dt;
                DataRow   dr;

                //Lấy mã hóa đơn bán của khách hàng hiện tại để xóa trên bảng hóa đơn bán
                dt = BUS_HDB.hienthiHDB();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        if (dr[2].ToString() == txtMaKhachHang.Text)
                        {
                            idkh.Add(dr["IdHDB"].ToString());
                        }
                    }
                }

                //Xóa trên bảng hóa đơn bán và hóa đơn bán chi tiết
                foreach (string item in idkh)
                {
                    BUS_HDB.RunDelSQLOnHDBCT(item);
                    BUS_HDB.RunDelSQL(item);
                }

                BUS_KH.RunDelSQL(txtMaKhachHang.Text);
                LoadDataGridView();
                ResetValues();
            }
            DANGNHAP.thaotac += "Xoá, ";
        }
Example #6
0
 private void txthsl_TextChanged(object sender, EventArgs e)
 {
     if (txthsl.Text.Trim().Length > 0 && txtluongcb.Text.Length > 0)
     {
         float a = 0;
         if (!float.TryParse(BUS_HDB.ConvertToFloatType(txthsl.Text), out a))
         {
             txtthuclinh.Text = string.Empty;
         }
         else
         {
             txtthuclinh.Text = Math.Round((Int64.Parse(BUS_HDB.ConvertToFloatType(txtluongcb.Text)) * a)).ToString();
             txtthuclinh.Text = BUS_HDB.FormatNumber(txtthuclinh.Text);
         }
     }
     else
     {
         txtthuclinh.Text = string.Empty;
     }
 }
Example #7
0
 private void txtSoLuongNhap_Leave(object sender, EventArgs e)
 {
     if (txtSoLuongNhap.Text != "")
     {
         Int64 a = 0;
         if (!Int64.TryParse(BUS_HDB.ConvertToFloatType(txtSoLuongNhap.Text), out a))
         {
             MessageBox.Show("Giá trị phải là số!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtSoLuongNhap.Focus();
         }
         else
         {
             if (a <= 0)
             {
                 MessageBox.Show("Giá trị hợp lệ phải > 0 !", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtSoLuongNhap.Focus();
             }
             else
             {
                 txtSoLuongNhap.Text = BUS_HDB.FormatNumber(a.ToString());
             }
         }
     }
 }
Example #8
0
        private void DGVNhanVien_Click(object sender, EventArgs e)
        {
            if (DGVNhanVien.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (DGVNhanVien.CurrentRow.Index == DGVNhanVien.NewRowIndex)
            {
                MessageBox.Show("Hãy chọn dòng có thông tin!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            dgvnvclick         = true;
            txtMaNhanVien.Text = DGVNhanVien.CurrentRow.Cells["IdNV"].Value.ToString();
            if (txtMaNhanVien.Text.Substring(0, 3) == "NQT")
            {
                rdbquantri.Checked = true;
                rdbketoan.Checked  = false;
                rdbbanhang.Checked = false;
                rdbthukho.Checked  = false;
            }
            if (txtMaNhanVien.Text.Substring(0, 3) == "NKT")
            {
                rdbquantri.Checked = false;
                rdbketoan.Checked  = true;
                rdbbanhang.Checked = false;
                rdbthukho.Checked  = false;
            }
            if (txtMaNhanVien.Text.Substring(0, 3) == "NBH")
            {
                rdbquantri.Checked = false;
                rdbketoan.Checked  = false;
                rdbbanhang.Checked = true;
                rdbthukho.Checked  = false;
            }
            if (txtMaNhanVien.Text.Substring(0, 3) == "NTK")
            {
                rdbquantri.Checked = false;
                rdbketoan.Checked  = false;
                rdbbanhang.Checked = false;
                rdbthukho.Checked  = true;
            }

            txtTenNhanVien.Text = DGVNhanVien.CurrentRow.Cells["TenNV"].Value.ToString();
            if (DGVNhanVien.CurrentRow.Cells["Gioitinh"].Value.ToString() == "Nam")
            {
                chkGioitinh.Checked = true;
            }
            else
            {
                chkGioitinh.Checked = false;
            }
            txtDiaChi.Text    = DGVNhanVien.CurrentRow.Cells["DiaChi"].Value.ToString();
            mskDienthoai.Text = DGVNhanVien.CurrentRow.Cells["SĐT"].Value.ToString();
            dtpNgaySinh.Text  = DGVNhanVien.CurrentRow.Cells["NgaySinh"].Value.ToString();
            txtchucvu.Text    = DGVNhanVien.CurrentRow.Cells["ChucVu"].Value.ToString();
            txtluongcb.Text   = BUS_HDB.FormatNumber(DGVNhanVien.CurrentRow.Cells["LuongCB"].Value.ToString());
            txthsl.Text       = BUS_HDB.FormatNumber(DGVNhanVien.CurrentRow.Cells["hsl"].Value.ToString());
            txtthuclinh.Text  = BUS_HDB.FormatNumber(DGVNhanVien.CurrentRow.Cells["Thuclinh"].Value.ToString());
            txttaikhoan.Text  = DGVNhanVien.CurrentRow.Cells["Taikhoan"].Value.ToString();
        }
Example #9
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string gt;

            if (nv.Rows.Count == 0)
            {
                MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtMaNhanVien.Text == "")
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtTenNhanVien.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenNhanVien.Focus();
                return;
            }
            if (txtDiaChi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiaChi.Focus();
                return;
            }
            if (mskDienthoai.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                mskDienthoai.Focus();
                return;
            }
            if (chkGioitinh.Checked == true)
            {
                gt = "Nam";
            }
            else
            {
                gt = "Nữ";
            }
            //mã nhân viên đã thay đổi so với ban đầu do đổi nhóm nhân viên của nv hiện tại
            if (txtMaNhanVien.Text.Substring(0, 3) != DGVNhanVien.CurrentRow.Cells["IdNV"].Value.ToString().Substring(0, 3))
            {
                //xóa nhân viên hiện tại
                List <string> idnd = new List <string>();

                DataTable dt;
                DataRow   dr;
                //Lấy mã người dùng của nhân viên hiện tại trên bảng người dùng.
                dt = BUS_ND.hienthiND();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < BUS_ND.hienthiND().Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        idnd.Add(dr["IdND"].ToString());
                    }
                }

                //Xóa trên bảng hóa đơn bán chi tiết và bảng hóa đơn bán
                dt = BUS_NV.layMaHDBTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_HDB.RunDelSQLOnHDBCT(dr[0].ToString());
                        BUS_HDB.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên bảng hóa đơn nhập chi tiết và bảng hóa đơn nhập
                dt = BUS_NV.LayMaHDNTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_HDN.RunDelSQLOnHDNCT(dr[0].ToString());
                        BUS_HDN.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên bảng công nợ chi tiết và bảng công nợ
                dt = BUS_NV.LayMaCNTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_CN.RunDelSQLOnCNCT(dr[0].ToString());
                        BUS_CN.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên bảng hàng tồn chi tiết và bảng hàng tồn
                dt = BUS_NV.LayMaHTTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_HT.RunDelSQLOnHTCT(dr[0].ToString());
                        BUS_HT.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên thống kê doanh thu
                dt = BUS_NV.LayMaDTTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_DT.RunDelSQL(dr[0].ToString());
                    }
                }

                foreach (string items in idnd)
                {
                    BUS_ND.RunDelSQLOnTC(items); //xoá trên bảng truy cập
                    BUS_ND.RunDelSQL(items);
                }

                BUS_NV.RunDelSQL(DGVNhanVien.CurrentRow.Cells["IdNV"].Value.ToString());

                //thêm mới nhân viên
                DTO_NV nv = new DTO_NV(txtMaNhanVien.Text, txtTenNhanVien.Text.Trim(), dtpNgaySinh.Text, gt, mskDienthoai.Text.Trim(), txtDiaChi.Text.Trim(), tencv, BUS_HDB.ConvertToFloatType(txtluongcb.Text.Trim()), txthsl.Text.Trim(), BUS_HDB.ConvertToFloatType(txtthuclinh.Text), txttaikhoan.Text);
                BUS_NV.themnv(nv);

                LoadDataGridView();
                ResetValues();
                DANGNHAP.thaotac += "Sửa, ";
            }
            else
            {
                DTO_NV nv = new DTO_NV(txtMaNhanVien.Text, txtTenNhanVien.Text.Trim(), dtpNgaySinh.Text, gt, mskDienthoai.Text.Trim(), txtDiaChi.Text.Trim(), tencv, BUS_HDB.ConvertToFloatType(txtluongcb.Text.Trim()), txthsl.Text.Trim(), BUS_HDB.ConvertToFloatType(txtthuclinh.Text), txttaikhoan.Text);

                BUS_NV.suaNV(nv);
                LoadDataGridView();
                ResetValues();
                DANGNHAP.thaotac += "Sửa, ";
            }
        }
Example #10
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (nv.Rows.Count == 0)
            {
                MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtMaNhanVien.Text == "")
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show("Xoá nhân viên sẽ xoá tất cả dữ liệu của nhân viên trên bảng người dùng, bảng truy cập, bảng hoá đơn bán chi tiết, bảng hoá đơn nhập chi tiết, bảng hoá đơn nhập, bảng hoá đơn bán. Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                //xóa nhân viên hiện tại
                List <string> idnd = new List <string>();

                DataTable dt;
                DataRow   dr;
                //Lấy mã người dùng của nhân viên hiện tại trên bảng người dùng.
                dt = BUS_ND.hienthiND();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < BUS_ND.hienthiND().Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        if (dr[2].ToString() == txtMaNhanVien.Text)
                        {
                            idnd.Add(dr["IdND"].ToString());
                        }
                    }
                }

                //Xóa trên bảng hóa đơn bán chi tiết và bảng hóa đơn bán
                dt = BUS_NV.layMaHDBTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_HDB.RunDelSQLOnHDBCT(dr[0].ToString());
                        BUS_HDB.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên bảng hóa đơn nhập chi tiết và bảng hóa đơn nhập
                dt = BUS_NV.LayMaHDNTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_HDN.RunDelSQLOnHDNCT(dr[0].ToString());
                        BUS_HDN.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên bảng công nợ chi tiết và bảng công nợ
                dt = BUS_NV.LayMaCNTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_CN.RunDelSQLOnCNCT(dr[0].ToString());
                        BUS_CN.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên bảng hàng tồn chi tiết và bảng hàng tồn
                dt = BUS_NV.LayMaHTTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_HT.RunDelSQLOnHTCT(dr[0].ToString());
                        BUS_HT.RunDelSQL(dr[0].ToString());
                    }
                }

                //Xóa trên thống kê doanh thu
                dt = BUS_NV.LayMaDTTheoMaNV(txtMaNhanVien.Text);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; ++i)
                    {
                        dr = dt.Rows[i];
                        BUS_DT.RunDelSQL(dr[0].ToString());
                    }
                }

                foreach (string items in idnd)
                {
                    BUS_ND.RunDelSQLOnTC(items); //xoá trên bảng truy cập
                    BUS_ND.RunDelSQL(items);
                }

                BUS_NV.RunDelSQL(DGVNhanVien.CurrentRow.Cells["IdNV"].Value.ToString());

                LoadDataGridView();
                ResetValues();
                DANGNHAP.thaotac += "Xoá, ";
            }
        }
Example #11
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            string gt;

            if (txtMaNhanVien.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNhanVien.Focus();
                return;
            }
            if (txtTenNhanVien.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenNhanVien.Focus();
                return;
            }
            if (txtDiaChi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiaChi.Focus();
                return;
            }
            if (mskDienthoai.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                mskDienthoai.Focus();
                return;
            }
            if (txtluongcb.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập lương cơ bản", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtluongcb.Focus();
                return;
            }
            if (txthsl.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập hệ số lương", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txthsl.Focus();
                return;
            }


            if (chkGioitinh.Checked == true)
            {
                gt = "Nam";
            }
            else
            {
                gt = "Nữ";
            }

            if (!BUS_NV.ktnvtrung(txtMaNhanVien.Text))
            {
                MessageBox.Show("Mã nhân viên này đã có! Hãy nhập mã khác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNhanVien.Focus();
                return;
            }
            DTO_NV nv = new DTO_NV(txtMaNhanVien.Text, txtTenNhanVien.Text, dtpNgaySinh.Text, gt, mskDienthoai.Text, txtDiaChi.Text, tencv, BUS_HDB.ConvertToFloatType(txtluongcb.Text), txthsl.Text, BUS_HDB.ConvertToFloatType(txtthuclinh.Text), txttaikhoan.Text);

            BUS_NV.themnv(nv);
            LoadDataGridView();
            ResetValues();

            //thêm dữ liệu cho danh mục quản lý truy cập
            DANGNHAP.thaotac += "Thêm, ";
        }
Example #12
0
        private void txtconnoncu_TextChanged(object sender, EventArgs e)
        {
            string conno = BUS_HDB.ConvertToFloatType(txtconnoncu.Text);

            txtconnoncu.Text = BUS_HDB.FormatNumber(conno);
        }
Example #13
0
        private void txtdoanhthu_TextChanged(object sender, EventArgs e)
        {
            string doanhthu = BUS_HDB.ConvertToFloatType(txtdoanhthu.Text);

            txtdoanhthu.Text = BUS_HDB.FormatNumber(doanhthu);
        }
Example #14
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (sp.Rows.Count == 0)
            {
                MessageBox.Show("Không còn dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (txtMaSanPham.Text == "Mã sản phẩm sẽ tự động thêm!")
            {
                MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (txtTenSanPham.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập tên hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTenSanPham.Focus();
                return;
            }
            if (cbMaNCU.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã nhà cung ứng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbMaNCU.Focus();
                return;
            }
            if (txtnhasx.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập nhà sản xuất", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtnhasx.Focus();
                return;
            }
            if (txtDonGiaNhap.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập đơn giá nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDonGiaNhap.Focus();
                return;
            }
            if (txtDonGiaBanLe.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập dơn giá bán lẻ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtDonGiaBanLe.Focus();
                return;
            }
            if (txtdongiabansi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập đơn giá bán sỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtdongiabansi.Focus();
                return;
            }
            if (txtdonvi.Text == "Vd: Chiếc, Cái, Hộp, ...")
            {
                MessageBox.Show("Bạn phải nhập đơn vị", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtdonvi.Focus();
                return;
            }

            Random rand  = new Random();
            string anhsp = Application.StartupPath + @"\Images Resource\" + "Image_" + rand.Next(1, 1000000000) + ".jpg";

            File.Copy(richtxtAnhSanPham.Text, anhsp);

            DTO_SP SP = new DTO_SP(txtMaSanPham.Text, cbMaNCU.Text, txtTenSanPham.Text, dtpNgaySX.Text, dtpngayhh.Text, dtpngaynhap.Text, txtnhasx.Text, BUS_HDB.ConvertToFloatType(txtSoLuongNhap.Text), BUS_HDB.ConvertToFloatType(txtDonGiaNhap.Text), BUS_HDB.ConvertToFloatType(txtDonGiaBanLe.Text), BUS_HDB.ConvertToFloatType(txtdongiabansi.Text), txtdonvi.Text, txtgiamgia.Text, anhsp);

            BUS_SP.suaSP(SP);

            LoadDataGridView();
            ResetValues();

            DANGNHAP.thaotac += "Sửa, ";
        }
Example #15
0
        private void txtloinhuan_TextChanged(object sender, EventArgs e)
        {
            string loinhuan = BUS_HDB.ConvertToFloatType(txtloinhuan.Text);

            txtloinhuan.Text = BUS_HDB.FormatNumber(loinhuan);
        }
Example #16
0
        private void txtslton_TextChanged(object sender, EventArgs e)
        {
            string cn = BUS_HDB.ConvertToFloatType(txtslton.Text);

            txtslton.Text = BUS_HDB.FormatNumber(cn);
        }
Example #17
0
        private void txtDoanhSoban_TextChanged(object sender, EventArgs e)
        {
            string doanhsoban = BUS_HDB.ConvertToFloatType(txtDoanhSoban.Text);

            txtDoanhSoban.Text = BUS_HDB.FormatNumber(doanhsoban);
        }