Exemple #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (comboBoxCHNhan.SelectedValue.ToString() == comboBoxCHPP.SelectedValue.ToString())
     {
         MessageBox.Show("Lỗi! Hai Cửa Hàng Trùng Nhau.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (numericUpDownThemBotSL.Value <= Convert.ToInt32(textBoxSLTonCHPP.Text) && numericUpDownThemBotSL.Value > 0)
         {
             string id1 = comboBoxCHNhan.SelectedValue.ToString();
             string id2 = comboBoxCHPP.SelectedValue.ToString();
             string id  = textBoxMaKieu.Text;
             KhoHangBUS.KiemTraKho_CuaHang_MaKieu(id, id1);
             KhoHangBUS.KiemTraKho_CuaHang_MaKieu(id, id2);
             int sl = Convert.ToInt32(numericUpDownThemBotSL.Value);
             try{
                 ChiTietSPBUS.PhanChiSP(id, id1, id2, sl);
                 MessageBox.Show("Thành Công! Sản Phẩm Đã Được Phân Phối.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 khoHangBindingSource.DataSource = KhoHangBUS.GetAllKhoHangByMaKieu(id);
             }
             catch
             {
                 MessageBox.Show("Lỗi! Không Thể Thực Hiện Thao Tác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Lỗi! Số Lượng Phân Phối Không Phù Hợp.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #2
0
 private void btnThemSPMua_Click(object sender, EventArgs e)
 {
     IsAdd = true;
     textBoxNSX.Visible           = false;
     textBoxLoaiSP.Visible        = false;
     textBoxDSP.Visible           = false;
     textBoxMauKieu.Visible       = false;
     textBoxMaKieuSP.Visible      = false;
     textBoxSP.Visible            = false;
     numericSL.Value              = 1;
     numericSL.Minimum            = 0;
     textboxGiaBan.Text           = "";
     textBoxSLTon.Text            = "";
     textBoxSLMua.Text            = "";
     textBoxTenSP.Text            = "";
     comboBoxMaKieu.DataSource    = null;
     comboBoxSP.DataSource        = null;
     comboBoxNSX.DataSource       = HSXBUS.GetAllHSX();
     comboBoxNSX.ValueMember      = "MaHSX";
     comboBoxNSX.DisplayMember    = "TenHSX";
     comboBoxMau.DataSource       = ChiTietSPBUS.GetAllMauSP();
     comboBoxMau.DisplayMember    = "Mau";
     comboBoxMau.ValueMember      = "MaMau";
     comboBoxLoaiSP.DataSource    = LoaiSPBUS.GetAllLoaiSP();
     comboBoxLoaiSP.DisplayMember = "TenLSP";
     comboBoxLoaiSP.ValueMember   = "MaLSP";
 }
Exemple #3
0
        private void dgvHoaDon_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            textBoxNSX.Visible      = true;
            textBoxLoaiSP.Visible   = true;
            textBoxDSP.Visible      = true;
            textBoxMauKieu.Visible  = true;
            textBoxMaKieuSP.Visible = true;
            textBoxSP.Visible       = true;

            int    r  = dgvHoaDon.CurrentCell.RowIndex;
            string id = dgvHoaDon.Rows[r].Cells[1].Value.ToString();
            USP_GETAllInfoSPNew_Result sp = ChiTietSPBUS.GetMaSPByMaKieuSP(id);

            textBoxNSX.Text      = sp.TenHSX;
            textBoxLoaiSP.Text   = sp.TenLSP;
            textBoxDSP.Text      = sp.TenDong;
            textboxGiaBan.Text   = dgvHoaDon.Rows[r].Cells[3].Value.ToString();
            textBoxSLTon.Text    = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDKieuSP(textBoxMaCH.Text, id).SoluongSP.ToString();
            textBoxMaKieuSP.Text = sp.MaKieu;
            textBoxTenSP.Text    = sp.TenSP;
            textBoxSLMua.Text    = dgvHoaDon.Rows[r].Cells[2].Value.ToString();
            ChiTietSP ct = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(id);

            textBoxSP.Text      = ct.MaSP.ToString();
            textBoxMauKieu.Text = ct.MaMau.ToString();

            try
            {
                pictureBox.BackgroundImage = ConverBinaryToImage(ct.Anh);
            }
            catch
            { pictureBox.BackgroundImage = null; }
        }
Exemple #4
0
        private void btnHuyKieuSP_Click(object sender, EventArgs e)
        {
            dgvCTSP.Enabled           = true;
            btnLuuKieuSP.Visible      = false;
            btnHuyKieuSP.Visible      = false;
            btnThemKieuSP.Visible     = true;
            btnChinhSuaKieuSP.Visible = true;
            btnXoaKieuSP.Visible      = true;
            textBoxMaKieu.ReadOnly    = false;
            textBoxMaSP.ReadOnly      = false;
            textBoxMaKieu.Visible     = false;
            textBoxMaSP.Visible       = false;
            cmBoxMauSP.DataSource     = ChiTietSPBUS.GetAllMauSP();
            cmBoxMauSP.ValueMember    = "MaMau";
            cmBoxMauSP.DisplayMember  = "Mau";
            textBoxMau.Visible        = false;
            int r = dgvCTSP.CurrentCell.RowIndex;

            textBoxMaKieu.Text          = dgvCTSP.Rows[r].Cells[1].Value.ToString();
            cmBoxMaKieuSP.SelectedValue = dgvCTSP.Rows[r].Cells[1].Value.ToString();
            textBoxMaSP.Text            = dgvCTSP.Rows[r].Cells[0].Value.ToString();
            cmBoxMaSP.SelectedValue     = dgvCTSP.Rows[r].Cells[0].Value.ToString();
            txtBoxGiaSP.Text            = dgvCTSP.Rows[r].Cells[3].Value.ToString();
            txtboxSoLuongAll.Text       = dgvCTSP.Rows[r].Cells[4].Value.ToString();
            cmBoxMauSP.SelectedValue    = dgvCTSP.Rows[r].Cells[2].Value.ToString();
        }
Exemple #5
0
        private void comboBoxMaKieu_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string id = comboBoxMaKieu.SelectedValue.ToString();

                ChiTietSP ct = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDKieuSP(textBoxMaCH.Text, id);
                if (ct != null)
                {
                    textBoxSLTon.Text         = ct.SoluongSP.ToString();
                    textboxGiaBan.Text        = ct.Gia.ToString();
                    comboBoxMau.SelectedValue = ct.MaMau;
                    try
                    {
                        pictureBox.BackgroundImage = ConverBinaryToImage(ct.Anh);
                    }
                    catch
                    {
                        pictureBox.BackgroundImage = null;
                    }
                }
                else
                {
                    textBoxSLTon.Text  = "";
                    textboxGiaBan.Text = "";
                }
            }
            catch
            {
                textBoxSLTon.Text  = "";
                textboxGiaBan.Text = "";
            }
        }
        private void dgvNhapHang_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                txtboxHSX.Visible    = true;
                txtBoxLSP.Visible    = true;
                txtBoxDSP.Visible    = true;
                txtboxGiaBan.Visible = true;
                txtBoxKieuSP.Visible = true;
                txtboxSP.Visible     = true;



                txtboxGiaBan.ReadOnly  = true;
                txtboxGiaNhap.ReadOnly = true;
                txtboxGiaBan.Visible   = true;

                int    r  = dgvNhapHang.CurrentCell.RowIndex;
                string id = dgvNhapHang.Rows[r].Cells[0].Value.ToString();
                USP_GETAllInfoSPNew_Result sp = ChiTietSPBUS.GetMaSPByMaKieuSP(id);
                txtboxHSX.Text     = sp.TenHSX;
                txtBoxLSP.Text     = sp.TenLSP;
                txtBoxDSP.Text     = sp.TenDong;
                txtboxGiaBan.Text  = sp.Gia.ToString();
                txtBoxSLTon.Text   = sp.SoluongSP.ToString();
                txtBoxKieuSP.Text  = sp.MaKieu;
                txtboxSP.Text      = sp.TenSP;
                txtboxGiaNhap.Text = dgvNhapHang.Rows[r].Cells[2].Value.ToString();
                textBoxSLNhap.Text = dgvNhapHang.Rows[r].Cells[1].Value.ToString();
            }
            catch { }
        }
Exemple #7
0
 void LoadSP()
 {
     try
     {
         Sp   = ChiTietSPBUS.GetMaSPByIDKieuSP(IDMaKieu);
         CtSp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(IDMaKieu);
         DSp  = DongSanPhamBUS.Get1DongSPByMaSP(Sp.MaDSP);
     }
     catch { }
 }
Exemple #8
0
        private void linklbChiTietSP_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (txtboxMaKieuSP.Text == "")
            {
                return;
            }
            frmChiTietSanPham ctsp = new frmChiTietSanPham(ChiTietSPBUS.GetMaSPByIDKieuSP(txtboxMaKieuSP.Text).MaSP, User.MaCuaHang, null, false);

            ctsp.ShowDialog();
        }
Exemple #9
0
 private void comboBoxSP_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         comboBoxMaKieu.DataSource = null;
         string id = comboBoxSP.SelectedValue.ToString();
         comboBoxMaKieu.DataSource    = ChiTietSPBUS.GetChiTietSPByIDSP(id);
         comboBoxMaKieu.DisplayMember = "MaKieu";
         comboBoxMaKieu.ValueMember   = "MaKieu";
     }
     catch { }
 }
Exemple #10
0
 private void btnXoaKieuSP_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn xóa dòng này không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         try
         {
             ChiTietSPBUS.XoaKieuSp(cmBoxMaKieuSP.SelectedValue.ToString());
             MessageBox.Show("Xóa Thành Công!", "Thông Báo");
             string id = cmBoxMaSP.SelectedValue.ToString();
             chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id);
         }
         catch { MessageBox.Show("Không Thể Thực Hiện Thao Tác!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); }
     }
 }
Exemple #11
0
 private void comboBoxCHPP_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         textBoxSLTonCHPP.Text = "";
         string    id = comboBoxCHPP.SelectedValue.ToString();
         ChiTietSP ct = new ChiTietSP();
         if (textBoxMaKieu.Text.Trim(' ') != "")
         {
             ct = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDKieuSP(id, textBoxMaKieu.Text);
         }
         else
         {
             ct = null;
         }
         textBoxSLTonCHPP.Text = ct.SoluongSP.ToString();
     }
     catch { }
 }
Exemple #12
0
        private void cmBoxMaKieuSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string id = cmBoxMaKieuSP.SelectedValue.ToString();
                //ChiTietSP sp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(id);
                if (IDMode == "ts")
                {
                    ChiTietSP sp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(id);
                    cmBoxMauSP.DataSource    = ChiTietSPBUS.GetAllMauSP();
                    cmBoxMauSP.ValueMember   = "MaMau";
                    cmBoxMauSP.DisplayMember = "Mau";
                    cmBoxMauSP.SelectedValue = sp.MaMau;
                    txtBoxGiaSP.Text         = sp.Gia.ToString();
                    txtboxSoLuongAll.Text    = sp.SoluongSP.ToString();
                    //picBoxKieuSP.Image = null;
                    picBoxKieuSP.BackgroundImage = null;
                    textBoxPathAnh.Text          = "";
                    //picBoxKieuSP.Image = ConverBinaryToImage(sp.Anh);
                    picBoxKieuSP.BackgroundImage = ConverBinaryToImage(sp.Anh);
                }
                else
                {
                    ChiTietSP sp = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDKieuSP(IDMode, id);

                    cmBoxMauSP.SelectedValue = sp.MaMau;
                    txtBoxGiaSP.Text         = sp.Gia.ToString();
                    txtboxSoLuongAll.Text    = sp.SoluongSP.ToString();
                    //picBoxKieuSP.Image = null;
                    picBoxKieuSP.BackgroundImage = null;
                    textBoxPathAnh.Text          = "";
                    //picBoxKieuSP.Image = ConverBinaryToImage(sp.Anh);
                    picBoxKieuSP.BackgroundImage = ConverBinaryToImage(sp.Anh);
                }
                //cmBoxMauSP.SelectedValue = sp.MaMau;
                //txtBoxGiaSP.Text = sp.Gia.ToString();
                //txtboxSoLuongAll.Text = sp.SoluongSP.ToString();
                //picBoxKieuSP.Image = null;
                //textBoxPathAnh.Text = "";
                //picBoxKieuSP.Image = ConverBinaryToImage(sp.Anh);
            }
            catch { }
        }
        private void cmBoxSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string id = cmBoxSP.SelectedValue.ToString();


                if (ChiTietSPBUS.GetChiTietSPByIDSP(id).Count != 0)
                {
                    cmBoxKieuSP.DataSource    = ChiTietSPBUS.GetChiTietSPByIDSP(id);
                    cmBoxKieuSP.DisplayMember = "MaKieu";
                    cmBoxKieuSP.ValueMember   = "MaKieu";
                }
                else
                {
                    cmBoxKieuSP.DataSource = null;
                }
            }
            catch { cmBoxKieuSP.DataSource = null; }
        }
Exemple #14
0
        private void comboBoxSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string id = comboBoxSP.SelectedValue.ToString();

                textBoxTenSP.Text = SanPhamBUS.GetSanPhamByID(id).TenSP.ToString();
                if (ChiTietSPBUS.GetChiTietSPByIDSP(id).Count != 0)
                {
                    comboBoxMaKieu.DataSource    = ChiTietSPBUS.GetChiTietSPByIDSP(id);
                    comboBoxMaKieu.DisplayMember = "MaKieu";
                    comboBoxMaKieu.ValueMember   = "MaKieu";
                }
                else
                {
                    comboBoxMaKieu.DataSource = null;
                }
            }
            catch { comboBoxMaKieu.DataSource = null; }
        }
Exemple #15
0
        private void btnThemKieuSP_Click(object sender, EventArgs e)
        {
            NewCTSP = true;

            dgvCTSP.Enabled = false;

            cmBoxMauSP.DataSource     = ChiTietSPBUS.GetAllMauSP();
            cmBoxMauSP.ValueMember    = "MaMau";
            cmBoxMauSP.DisplayMember  = "Mau";
            textBoxMaKieu.Visible     = true;
            textBoxMaKieu.Text        = "";
            textBoxMaSP.Visible       = true;
            txtBoxGiaSP.Text          = "0";
            txtboxSoLuongAll.Text     = "0";
            btnLuuKieuSP.Visible      = true;
            btnHuyKieuSP.Visible      = true;
            btnThemKieuSP.Visible     = false;
            btnChinhSuaKieuSP.Visible = false;
            btnXoaKieuSP.Visible      = false;
            textBoxMaSP.Text          = cmBoxMaSP.SelectedValue.ToString();
        }
Exemple #16
0
 private void comboBoxMaKieu_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         textBoxSLTonKieu.Text           = "";
         pictureBox.BackgroundImage      = null;
         khoHangBindingSource.DataSource = null;
         textBoxMaKieu.Text = "";
         string id = comboBoxMaKieu.SelectedValue.ToString();
         CtSp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(id);
         textBoxMaKieu.Text    = CtSp.MaKieu;
         textBoxSLTonKieu.Text = CtSp.SoluongSP.ToString();
         try
         {
             pictureBox.BackgroundImage = ConverBinaryToImage(CtSp.Anh);
         }
         catch { pictureBox.BackgroundImage = null; }
         khoHangBindingSource.DataSource = KhoHangBUS.GetAllKhoHangByMaKieu(CtSp.MaKieu);
     }
     catch { }
 }
Exemple #17
0
        private void btnLuuHD_Click(object sender, EventArgs e)
        {
            HoaDon hd = new HoaDon();

            hd.MaHoaDon  = textBoxMaHD.Text;
            hd.MaKH      = comboBoxMaKH.SelectedValue.ToString();
            hd.MaNV      = textBoxMaNV.Text;
            hd.MaCuaHang = textBoxMaCH.Text;
            hd.NgayLapHD = dateTimePickerNgayVietHD.Value;
            hd.TinhTrang = 0;
            if (radioMuaTT.Checked)
            {
                hd.HTGiaoHang = "Trực Tiếp";
            }
            else
            {
                hd.HTGiaoHang = "Giao Hàng";
            }
            try
            {
                HoaDonBUS.ThemHoaDon(hd);
                MessageBox.Show("Thêm Thành Công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                groupBox2.Enabled            = true;
                btnLuuTam.Visible            = true;
                btnThanhToan.Visible         = true;
                comboBoxNSX.DataSource       = HSXBUS.GetAllHSX();
                comboBoxNSX.ValueMember      = "MaHSX";
                comboBoxNSX.DisplayMember    = "TenHSX";
                comboBoxMau.DataSource       = ChiTietSPBUS.GetAllMauSP();
                comboBoxMau.DisplayMember    = "Mau";
                comboBoxMau.ValueMember      = "MaMau";
                comboBoxLoaiSP.DataSource    = LoaiSPBUS.GetAllLoaiSP();
                comboBoxLoaiSP.DisplayMember = "TenLSP";
                comboBoxLoaiSP.ValueMember   = "MaLSP";
            }
            catch
            {
                MessageBox.Show("Không Thể Thực Hiện Thao Tác!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #18
0
        private void cmBoxMaSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            string id = cmBoxMaSP.SelectedValue.ToString();

            //cmBoxMaKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id);
            //cmBoxMaKieuSP.DisplayMember = "MaKieu";
            //cmBoxMaKieuSP.ValueMember = "MaKieu";
            //cmBoxMauSP.DataSource = ChiTietSPBUS.GetAllMauSP();
            //cmBoxMauSP.ValueMember = "MaMau";
            //cmBoxMauSP.DisplayMember = "Mau";
            if (IDMode == "ts")
            {
                chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id);
                cmBoxMaKieuSP.DataSource          = ChiTietSPBUS.GetChiTietSPByIDSP(id);
                cmBoxMaKieuSP.DisplayMember       = "MaKieu";
                cmBoxMaKieuSP.ValueMember         = "MaKieu";
                cmBoxMauSP.DataSource             = ChiTietSPBUS.GetAllMauSP();
                cmBoxMauSP.ValueMember            = "MaMau";
                cmBoxMauSP.DisplayMember          = "Mau";
            }
            else
            {
                chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id);
                //cmBoxMaKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode,id);
                if (ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id).Count != 0)
                {
                    cmBoxMaKieuSP.DataSource    = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id);
                    cmBoxMaKieuSP.DisplayMember = "MaKieu";
                    cmBoxMaKieuSP.ValueMember   = "MaKieu";
                }
                else
                {
                    cmBoxMaKieuSP.DataSource = null;
                }
                cmBoxMauSP.DataSource    = ChiTietSPBUS.GetAllMauSP();
                cmBoxMauSP.ValueMember   = "MaMau";
                cmBoxMauSP.DisplayMember = "Mau";
            }
        }
Exemple #19
0
 private void cmBoxSP_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (ID != null)
         {
             string  id = cmBoxSP.SelectedValue.ToString();
             SanPham sp = SanPhamBUS.GetSanPhamByID(id);
             cmBoxMaSP.SelectedValue = id;
             cmBoxSP.SelectedValue   = id;
             txtboxMaSP.Text         = sp.MaSP;
             txtTenSP.Text           = sp.TenSP;
             txtNamSX.Text           = sp.NămSX;
             txtboxCPU.Text          = sp.CPU;
             txtboxGPU.Text          = sp.CardManHinh;
             txtCamera.Text          = sp.Camera;
             txtPort.Text            = sp.Port;
             txtboxRam.Text          = sp.Ram;
             txtboxManHinh.Text      = sp.ManHinh;
             txtboxOS.Text           = sp.OS;
             txtboxSim.Text          = sp.Sim;
             txtboxPin.Text          = sp.DungLuongPin;
             txtBoxTrongLuong.Text   = sp.TrongLuong;
             txtboxBNngoai.Text      = sp.BoNhoNgoai;
             txtboxBNtrong.Text      = sp.BoNhoTrong;
             if (IDMode == "ts")
             {
                 chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id);
             }
             else
             {
                 chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id);
             }
             //chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(ID);
         }
     }
     catch { }
 }
 private void btnThayDoiGia_Click(object sender, EventArgs e)
 {
     if (btnThayDoiGia.Text == "Đổi Giá")
     {
         btnThayDoiGia.Text    = "Lưu";
         txtboxGiaBan.ReadOnly = false;
     }
     else
     {
         if (btnThayDoiGia.Text == "Lưu")
         {
             try
             {
                 btnThayDoiGia.Text    = "Đổi Giá";
                 txtboxGiaBan.ReadOnly = true;
                 string  id  = cmBoxKieuSP.SelectedValue.ToString();
                 decimal gia = Convert.ToDecimal(txtboxGiaBan.Text);
                 ChiTietSPBUS.ThayDoiGiaChiTietSO(id, gia);
             }
             catch { }
         }
     }
 }
Exemple #21
0
        public void LoadChiTietSP()
        {
            //try
            //{
            LoadSP();
            //}
            //catch
            //{

            //}
            comboBoxCHNhan.DataSource    = CuaHangBUS.GetAllCuaHang();
            comboBoxCHNhan.DisplayMember = "TenCuaHang";
            comboBoxCHNhan.ValueMember   = "MaCuaHang";
            comboBoxCHPP.DataSource      = CuaHangBUS.GetAllCuaHang();
            comboBoxCHPP.DisplayMember   = "TenCuaHang";
            comboBoxCHPP.ValueMember     = "MaCuaHang";
            comboBoxNXS.DataSource       = HSXBUS.GetAllHSX();
            comboBoxNXS.DisplayMember    = "TenHSX";
            comboBoxNXS.ValueMember      = "MaHSX";
            comboBoxNXS.SelectedValue    = DSp.MaHSX;
            comboBoxDSP.DataSource       = DongSanPhamBUS.GetAllDongSPByMaHSX(DSp.MaHSX);
            comboBoxDSP.DisplayMember    = "TenDong";
            comboBoxDSP.ValueMember      = "MaDSP";
            comboBoxDSP.SelectedValue    = DSp.MaDSP;
            comboBoxSP.DataSource        = SanPhamBUS.GetSanPhamByMaDSP(DSp.MaDSP);
            comboBoxSP.DisplayMember     = "TenSP";
            comboBoxSP.ValueMember       = "MaSP";
            comboBoxSP.SelectedValue     = Sp.MaSP;
            comboBoxMaKieu.DataSource    = ChiTietSPBUS.GetChiTietSPByIDSP(Sp.MaSP);
            comboBoxMaKieu.DisplayMember = "MaKieu";
            comboBoxMaKieu.ValueMember   = "MaKieu";
            CtSp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(IDMaKieu);
            comboBoxMaKieu.SelectedValue    = CtSp.MaKieu;
            textBoxSLTonKieu.Text           = CtSp.SoluongSP.ToString();
            pictureBox.BackgroundImage      = ConverBinaryToImage(CtSp.Anh);
            khoHangBindingSource.DataSource = KhoHangBUS.GetAllKhoHangByMaKieu(CtSp.MaKieu);
        }
        private void cmBoxKieuSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string id = cmBoxKieuSP.SelectedValue.ToString();

                ChiTietSP ct = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(id);
                if (ct != null)
                {
                    txtBoxSLTon.Text  = ct.SoluongSP.ToString();
                    txtboxGiaBan.Text = ct.Gia.ToString();
                }
                else
                {
                    txtBoxSLTon.Text  = "";
                    txtboxGiaBan.Text = "";
                }
            }
            catch
            {
                txtBoxSLTon.Text  = "";
                txtboxGiaBan.Text = "";
            }
        }
Exemple #23
0
        void LoadSP()
        {
            cmBoxDongSP.Enabled    = true;
            cmBoxDongSP.DataSource = DongSanPhamBUS.GetAllDongSP();
            //cmBoxMauSP.DataSource = ChiTietSPBUS.GetAllMauSP();
            //cmBoxSP.DataSource = SanPhamBUS.GetSanPhamByMaDSP();
            cmBoxTenMau.DataSource    = ChiTietSPBUS.GetAllMauSP();
            cmBoxTenMau.DisplayMember = "Mau";
            cmBoxTenMau.ValueMember   = "MaMau";

            if (IDMode.Trim(' ') != "ts")
            {
                btnAnh.Visible            = false;
                btnThemSP.Visible         = false;
                btnLuuThayDoi.Visible     = false;
                btnLuuKieuSP.Visible      = false;
                btnHuyKieuSP.Visible      = false;
                btnThemKieuSP.Visible     = false;
                btnChinhSuaKieuSP.Visible = false;
                btnXoaKieuSP.Visible      = false;
                btnThemMau.Visible        = false;
                btnXoaMau.Visible         = false;
                btnLuuMau.Visible         = false;
            }
            //Xem Chi tiết
            if (ID != null && Ischange == false)
            {
                btnThemSP.Visible     = false;
                btnLuuThayDoi.Visible = false;
                SanPham sp = BUS.SanPhamBUS.GetSanPhamByID(ID);
                cmBoxSP.DataSource        = SanPhamBUS.GetSanPhamByMaDSP(sp.MaDSP);
                cmBoxSP.ValueMember       = "MaSP";
                cmBoxSP.DisplayMember     = "TenSP";
                cmBoxSP.SelectedValue     = ID;
                cmBoxDongSP.DisplayMember = "TenDong";
                cmBoxDongSP.ValueMember   = "MaDSP";
                cmBoxDongSP.SelectedValue = sp.MaDSP;
                cmBoxSP.SelectedValue     = ID;
                txtboxMaSP.Text           = sp.MaSP;
                txtTenSP.Text             = sp.TenSP;
                txtNamSX.Text             = sp.NămSX;
                txtboxCPU.Text            = sp.CPU;
                txtboxGPU.Text            = sp.CardManHinh;
                txtCamera.Text            = sp.Camera;
                txtPort.Text          = sp.Port;
                txtboxRam.Text        = sp.Ram;
                txtboxManHinh.Text    = sp.ManHinh;
                txtboxOS.Text         = sp.OS;
                txtboxSim.Text        = sp.Sim;
                txtboxPin.Text        = sp.DungLuongPin;
                txtBoxTrongLuong.Text = sp.TrongLuong;
                txtboxBNngoai.Text    = sp.BoNhoNgoai;
                txtboxBNtrong.Text    = sp.BoNhoTrong;
            }
            //Thêm Mới
            if (ID == null && Ischange == false)
            {
                cmBoxSP.Enabled           = false;
                cmBoxDongSP.DisplayMember = "TenDong";
                cmBoxDongSP.ValueMember   = "MaDSP";
                if (IDDSP != null)
                {
                    cmBoxDongSP.SelectedValue = IDDSP;
                }
                btnThemSP.Visible         = false;
                btnLuuThayDoi.Visible     = true;
                cmBoxSP.Visible           = false;
                txtTenSP.ReadOnly         = false;
                txtNamSX.ReadOnly         = false;
                txtboxCPU.ReadOnly        = false;
                txtboxGPU.ReadOnly        = false;
                txtCamera.ReadOnly        = false;
                txtPort.ReadOnly          = false;
                txtboxRam.ReadOnly        = false;
                txtboxManHinh.ReadOnly    = false;
                txtboxOS.ReadOnly         = false;
                txtboxSim.ReadOnly        = false;
                txtboxPin.ReadOnly        = false;
                txtBoxTrongLuong.ReadOnly = false;
                txtboxBNngoai.ReadOnly    = false;
                txtboxBNtrong.ReadOnly    = false;
            }
            //Chỉnh sửa
            if (ID != null && Ischange == true)
            {
                cmBoxSP.Enabled           = false;
                cmBoxDongSP.DisplayMember = "TenDong";
                cmBoxDongSP.ValueMember   = "MaDSP";
                btnThemSP.Visible         = false;
                btnLuuThayDoi.Visible     = true;
                cmBoxSP.Visible           = false;
                txtboxMaSP.Text           = ID;
                txtboxMaSP.ReadOnly       = true;
                txtTenSP.ReadOnly         = false;
                txtNamSX.ReadOnly         = false;
                txtboxCPU.ReadOnly        = false;
                txtboxGPU.ReadOnly        = false;
                txtCamera.ReadOnly        = false;
                txtPort.ReadOnly          = false;
                txtboxRam.ReadOnly        = false;
                txtboxManHinh.ReadOnly    = false;
                txtboxOS.ReadOnly         = false;
                txtboxSim.ReadOnly        = false;
                txtboxPin.ReadOnly        = false;
                txtBoxTrongLuong.ReadOnly = false;
                txtboxBNngoai.ReadOnly    = false;
                txtboxBNtrong.ReadOnly    = false;

                SanPham sp = BUS.SanPhamBUS.GetSanPhamByID(ID);
                cmBoxSP.DataSource        = SanPhamBUS.GetSanPhamByMaDSP(sp.MaDSP);
                cmBoxSP.ValueMember       = "MaSP";
                cmBoxSP.DisplayMember     = "MaSP";
                cmBoxSP.SelectedValue     = sp.MaSP;
                cmBoxDongSP.DisplayMember = "TenDong";
                cmBoxDongSP.ValueMember   = "MaDSP";
                cmBoxDongSP.SelectedValue = sp.MaDSP;
                txtboxMaSP.Text           = sp.MaSP;
                txtTenSP.Text             = sp.TenSP;
                txtNamSX.Text             = sp.NămSX;
                txtboxCPU.Text            = sp.CPU;
                txtboxGPU.Text            = sp.CardManHinh;
                txtCamera.Text            = sp.Camera;
                txtPort.Text          = sp.Port;
                txtboxRam.Text        = sp.Ram;
                txtboxManHinh.Text    = sp.ManHinh;
                txtboxOS.Text         = sp.OS;
                txtboxSim.Text        = sp.Sim;
                txtboxPin.Text        = sp.DungLuongPin;
                txtBoxTrongLuong.Text = sp.TrongLuong;
                txtboxBNngoai.Text    = sp.BoNhoNgoai;
                txtboxBNtrong.Text    = sp.BoNhoTrong;
            }
        }
Exemple #24
0
 public ActionResult Detail(int id)
 {
     return(View(ChiTietSPBUS.LoadSP(id)));
 }
Exemple #25
0
        private async void btnLuuKieuSP_Click(object sender, EventArgs e)
        {
            using (GalaxyMobileEntities db = new GalaxyMobileEntities())
            {
                ChiTietSP sp = new ChiTietSP();
                try
                {
                    // sp.Anh = CovertImageToBinary(picBoxKieuSP.Image);
                    sp.Anh = CovertImageToBinary(picBoxKieuSP.BackgroundImage);
                }
                catch
                {
                }
                sp.Gia       = 0;
                sp.SoluongSP = 0;
                sp.MaKieu    = textBoxMaKieu.Text;
                sp.MaSP      = /*textBoxMaSP.Text;*/ cmBoxMaSP.SelectedValue.ToString();
                sp.MaMau     = cmBoxMauSP.SelectedValue.ToString();
                try
                {
                    if (NewCTSP)
                    {
                        db.ChiTietSPs.Add(sp);
                        db.SaveChanges();
                        //    await db.SaveChangesAsync();
                        MessageBox.Show("Thêm Thành Công!", "Thông Báo");

                        ChiTietSPBUS.Them_CTSPMoi_Into_KhoHang_(sp.MaKieu);
                    }
                    else
                    {
                        try
                        {
                            // sp.Anh = CovertImageToBinary(picBoxKieuSP.Image);
                            sp.Anh = CovertImageToBinary(picBoxKieuSP.BackgroundImage);
                        }
                        catch
                        {
                            sp.Anh = ChiTietSPBUS.LayAnhKieuSP(cmBoxMaKieuSP.SelectedValue.ToString(), cmBoxMaSP.SelectedValue.ToString());
                        }

                        int r = dgvCTSP.CurrentCell.RowIndex;
                        //sp.Gia = Convert.ToDecimal(dgvCTSP.Rows[r].Cells[3].Value.ToString());
                        sp.Gia       = Convert.ToDecimal(txtBoxGiaSP.Text);
                        sp.SoluongSP = Convert.ToInt32(txtboxSoLuongAll.Text);
                        db.ChiTietSPs.Attach(sp);
                        db.Entry(sp).State = System.Data.Entity.EntityState.Modified;
                        await db.SaveChangesAsync();

                        MessageBox.Show("Thay Đổi Thành Công!", "Thông Báo");
                        string id = cmBoxMaSP.SelectedValue.ToString();
                        chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id);
                    }
                }
                catch { MessageBox.Show("Không Thể Thực Hiện Thao Tác!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            }
            btnLuuKieuSP.Visible      = false;
            btnHuyKieuSP.Visible      = false;
            btnThemKieuSP.Visible     = true;
            btnChinhSuaKieuSP.Visible = true;
            btnXoaKieuSP.Visible      = true;
            textBoxMaKieu.ReadOnly    = false;
            textBoxMaSP.ReadOnly      = false;
            textBoxMaKieu.Visible     = false;
            textBoxMaSP.Visible       = false;
            txtBoxGiaSP.ReadOnly      = true;
            textBoxMau.Visible        = false;
            dgvCTSP.Enabled           = true;
        }