private void bteSanPham_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { frmLookUp_SanPham frmLookUpSanPham = new frmLookUp_SanPham(false, String.Format("%{0}%", bteSanPham.Text)); if (frmLookUpSanPham.ShowDialog() == DialogResult.OK) { bteSanPham.Tag = frmLookUpSanPham.SelectedItem; bteSanPham.Text = frmLookUpSanPham.SelectedItem.TenSanPham; DMCauHinhSanPhamInfo obj = DMCauHinhSanPhamDataProvider.Instance.GetNhaCCByIdSanPham(((DMSanPhamInfo)bteSanPham.Tag).IdSanPham); txtNhaCC.Text = obj.Hang; try { string path = String.Format("http://logo.trananh.com.vn/{0}.jpg", txtNhaCC.Text); System.Net.WebRequest req = System.Net.WebRequest.Create(path); System.Net.WebResponse response = req.GetResponse(); System.IO.Stream stream = response.GetResponseStream(); if (path != null) { //Image im = new Bitmap(path, true); Image im = Image.FromStream(stream); pteLogo.Size = new Size(192, 83); pteLogo.Image = Crop(im, 192, 83, AnchorPosition.Center); } } catch (Exception) { clsUtils.MsgCanhBao("Sản phẩm chưa có Logo!"); } } } }
private void grcDMCauHinhSanPham_DoubleClick(object sender, EventArgs e) { //isAdd = false; if (grvDMCauHinhSanPham.FocusedRowHandle < 0) { return; } DMCauHinhSanPhamInfo info = ((DMCauHinhSanPhamInfo)grvDMCauHinhSanPham.GetRow(grvDMCauHinhSanPham.FocusedRowHandle)); List <DMCauHinhSanPhamInfo> lst = DMCauHinhSanPhamDataProvider.Instance.GetCauHinhByIdSanPham(info.IdSanPham); if (lst.Count == 0) { frm_ChiTiet_CauHinhSanPham frm = new frm_ChiTiet_CauHinhSanPham(this, info.IdSanPham, info.TenSanPham, "", ""); if (frm.ShowDialog() == DialogResult.OK) { grcDMCauHinhSanPham.DataSource = DMCauHinhSanPhamDataProvider.Instance.GetListCauHinhSanPham(); } } else { frm_ChiTiet_CauHinhSanPham frm = new frm_ChiTiet_CauHinhSanPham(this, info.IdSanPham, info.TenSanPham, lst[0].TenCauHinh, lst[0].GiaTri); if (frm.ShowDialog() == DialogResult.OK) { grcDMCauHinhSanPham.DataSource = DMCauHinhSanPhamDataProvider.Instance.GetListCauHinhSanPham(); } } }
private void frm_ChiTiet_CauHinhSanPham_Load(object sender, EventArgs e) { //if (frmCauHinh.isAdd) //{ // bteSanPham.Enabled = true; // txtNhaCC.Text = ""; // txtLogo.Text = ""; // //pteLogo. // //grcChiTietCauHinh.DataSource = lst; // grcChiTietCauHinh.DataSource = new BindingList<DMCauHinhSanPhamInfo>(lst) // { // AllowEdit = true, // AllowNew = true, // AllowRemove = true, // }; //} //else //{ txtLogo.Enabled = false; txtNhaCC.Enabled = false; bteSanPham.Tag = DmSanPhamProvider.GetSanPhamById(IdSanPham); bteSanPham.Text = TenSanPham; //txtLogo.Text = Logo; DMCauHinhSanPhamInfo nhaCC = DMCauHinhSanPhamDataProvider.Instance.GetNhaCCByIdSanPham(IdSanPham); txtNhaCC.Text = nhaCC.Hang; try { string path = String.Format("http://logo.trananh.com.vn/{0}.jpg", txtNhaCC.Text); System.Net.WebRequest req = System.Net.WebRequest.Create(path); System.Net.WebResponse response = req.GetResponse(); System.IO.Stream stream = response.GetResponseStream(); if (path != null) { //Image im = new Bitmap(path, true); Image im = Image.FromStream(stream); pteLogo.Image = im; //Crop(im, 192, 83, AnchorPosition.Center); } } catch (Exception) { clsUtils.MsgCanhBao("Sản phẩm chưa có Logo!"); } lst = DMCauHinhSanPhamDataProvider.Instance.GetCauHinhByIdSanPham(IdSanPham); grcChiTietCauHinh.DataSource = new BindingList <DMCauHinhSanPhamInfo>(lst) { AllowEdit = true, AllowNew = true, AllowRemove = true, }; //grcChiTietCauHinh.DataSource = null; //grcChiTietCauHinh.DataSource = lst; //} }
private void Delete() { if (grvDMCauHinhSanPham.FocusedRowHandle < 0) { return; } DMCauHinhSanPhamInfo info = ((DMCauHinhSanPhamInfo)grvDMCauHinhSanPham.GetRow(grvDMCauHinhSanPham.FocusedRowHandle)); DMCauHinhSanPhamDataProvider.Instance.Delete(new DMCauHinhSanPhamInfo { IdSanPham = info.IdSanPham }); }
public void SaoChep() { try { frmLookUp_SanPham frm = new frmLookUp_SanPham("%%"); if (frm.ShowDialog() == DialogResult.OK) { DMSanPhamInfo dmSanPhamInfo = frm.SelectedItem; if (DmCauHinhSanPhamDAO.Instance.DaCoCauHinh(View.IdSanPham)) { if ( MessageBox.Show("Sản phẩm này đã có cấu hình bạn có muốn ghi đè không ?", "Xác Nhận ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } else if ( MessageBox.Show("Bạn chắc chắn sẽ sao chép cấu hình cho sản phẩm ?", dmSanPhamInfo.MaSanPham, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } try { ConnectionUtil.Instance.BeginTransaction(); DmCauHinhSanPhamDAO.Instance.Delete(dmSanPhamInfo.IdSanPham); List <DMCauHinhSanPhamInfo> list = new List <DMCauHinhSanPhamInfo>(); for (int i = 0; i < list.Count; i++) { DMCauHinhSanPhamInfo info = list[i]; DmCauHinhSanPhamDAO.Instance.Update(info.IdSanPham, info.TenCauHinh, info.GiaTri, info.SoTT); ConnectionUtil.Instance.CommitTransaction(); } } catch (Exception) { { ConnectionUtil.Instance.RollbackTransaction(); throw; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSaoChep_Click(object sender, EventArgs e) { try { frmLookUp_SanPham frmLookUpSanPham = new frmLookUp_SanPham("%%"); if (frmLookUpSanPham.ShowDialog() == DialogResult.OK) { DMSanPhamInfo dmSanPhamInfo = frmLookUpSanPham.SelectedItem; if (DMCauHinhSanPhamDataProvider.Instance.DaCoCauHinh(dmSanPhamInfo.IdSanPham)) { if (MessageBox.Show("Sản phẩm này đã có cấu hình, bạn chắc chắn có muốn ghi đè không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } else if (MessageBox.Show("Bạn chắc chắn sẽ sao chép cấu hình cho sản phẩm " + dmSanPhamInfo.MaSanPham + " không?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } try { ConnectionUtil.Instance.BeginTransaction(); DMCauHinhSanPhamDataProvider.Instance.Delete(dmSanPhamInfo.IdSanPham); for (int i = 0; i < lst.Count; i++) { DMCauHinhSanPhamInfo infor = lst[i]; DMCauHinhSanPhamDataProvider.Instance.Insert(dmSanPhamInfo.IdSanPham, infor.TenCauHinh, infor.GiaTri, infor.SoTT); } ConnectionUtil.Instance.CommitTransaction(); } catch (Exception) { ConnectionUtil.Instance.RollbackTransaction(); throw; } } } catch (Exception ex) { #if DEBUG MessageBox.Show(ex.ToString()); #else MessageBox.Show(ex.Message); #endif } }
public void Update() { _cauhinhinfo.IdSanPham = View.IdSanPham; _cauhinhinfo.TenCauHinh = View.TenCauHinh; _cauhinhinfo.GiaTri = View.GiaTri; _cauhinhinfo.Hang = View.Hang; _cauhinhinfo.Logo = View.logo; _cauhinhinfo.SoTT = View.SoTT; List <DMCauHinhSanPhamInfo> list = new List <DMCauHinhSanPhamInfo>(); _cauhinhinfo = new DMCauHinhSanPhamInfo(); for (int i = 0; i < list.Count; i++) { DMCauHinhSanPhamInfo infor = list[i]; DmCauHinhSanPhamDAO.Instance.Update(_cauhinhinfo.IdSanPham, infor.TenCauHinh, _cauhinhinfo.GiaTri, _cauhinhinfo.SoTT); } ((List <DMCauHinhSanPhamInfo>)DSCauHinhSanPhamView.Instance.DataSource).Add(_cauhinhinfo); DSCauHinhSanPhamView.Instance.RefreshDataSource(); }
private void Save() { if (Check()) { try { ConnectionUtil.Instance.BeginTransaction(); if (TenCauHinh == "" && GiaTri == "") { DMSanPhamInfo obj = (DMSanPhamInfo)bteSanPham.Tag; for (int i = 0; i < lst.Count; i++) { DMCauHinhSanPhamInfo infor = lst[i]; DMCauHinhSanPhamDataProvider.Instance.Insert(obj.IdSanPham, infor.TenCauHinh, infor.GiaTri, infor.SoTT); } //DMCauHinhSanPhamDataProvider.Instance.UpdateLogo(obj.IdSanPham, txtLogo.Text); ConnectionUtil.Instance.CommitTransaction(); } else { //DMSanPhamInfo obj = (DMSanPhamInfo)bteSanPham.Tag; for (int i = 0; i < lst.Count; i++) { DMCauHinhSanPhamInfo infor = lst[i]; DMCauHinhSanPhamDataProvider.Instance.Update(IdSanPham, infor.TenCauHinh, infor.GiaTri, infor.SoTT); } //DMCauHinhSanPhamDataProvider.Instance.UpdateLogo(IdSanPham, txtLogo.Text); ConnectionUtil.Instance.CommitTransaction(); } } catch (Exception) { ConnectionUtil.Instance.RollbackTransaction(); throw; } } }
private void GetData() { _cauhinhinfo = View.cauhinhspinfo; }
//public bool IsExisted(DMCauHinhSanPhamInfo dmCauHinhSanPhamInfo) //{ // return DmCauHinhSanPhamDAO.Instance.Exist(dmCauHinhSanPhamInfo); //} public bool IsUsed(DMCauHinhSanPhamInfo checkInfo) { return(false); }
public bool IsExisted(DMCauHinhSanPhamInfo checkInfo) { throw new NotImplementedException(); }
public void Delete(DMCauHinhSanPhamInfo dmCauHinhSanPhamInfo) { DmCauHinhSanPhamDAO.Instance.Delete(dmCauHinhSanPhamInfo); }
public List <DMCauHinhSanPhamInfo> Search(DMCauHinhSanPhamInfo match) { return(DmCauHinhSanPhamDAO.Instance.Search(match)); }
//public bool Exist(DMCauHinhSanPhamInfo dmCauHinhSanPhamInfo) //{ // ExecuteCommand(Declare.StoreProcedureNamespace.spDuAnExist, dmDuAnInfor.IdDuAn, dmDuAnInfor.MaDuAn); // return Convert.ToInt32(Parameters["p_Count"].Value) == 1; //} internal List <DMCauHinhSanPhamInfo> Search(DMCauHinhSanPhamInfo dmCauHinhSanPhamInfo) { return(GetListCommand <DMCauHinhSanPhamInfo>(Declare.StoreProcedureNamespace.spCauHinhSanPhamSearch, dmCauHinhSanPhamInfo.TenCauHinh, dmCauHinhSanPhamInfo.GiaTri)); }
internal void Delete(DMCauHinhSanPhamInfo dmCauHinhSanPhamInfo) { ExecuteCommand(Declare.StoreProcedureNamespace.spCauHinhSanPhamDelete, dmCauHinhSanPhamInfo.IdSanPham); }