public static void SuaHh(CHangHoa hh) { try { HangHoa dao = new HangHoa(); dao.SuaHangHoa(hh); } catch (SqlException ex) { throw ex; } }
public static void ThemHH(CHangHoa hh) { try { HangHoa dao = new HangHoa(); dao.ThemHangHoa(hh); } catch (SqlException ex) { throw ex; } }
private void xlThem() { try { File.Copy(sourceImg, pathPictureFolder + nameImage); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CHangHoa hh = new CHangHoa ( txtMa.Text, txtTen.Text, int.Parse(cbLoaiHH.EditValue.ToString()), lePhanLoai.EditValue.ToString(), leKhoMacDinh.EditValue.ToString(), leDonVi.EditValue.ToString(), nameImage, calcGiaSi.Text == ""? 0 :float.Parse(calcGiaSi.Text), calcGiaMua.Text == "" ? 0 : float.Parse(calcGiaMua.Text), calcGiaLe.Text == "" ? 0 : float.Parse(calcGiaLe.Text), leNCC.Text == ""?"":leNCC.EditValue.ToString(), leNCC.EditValue.ToString() == "" ? "" : leNCC.Text, calcTonKhoToiThieu.Text == "" ? 0 : int.Parse(calcTonKhoToiThieu.Text), checkConQL.Checked ); BUS_HangHoa.ThemHH(hh); sendHH?.Invoke(); Action.Module = "Hàng Hóa"; Action.ActionName = "Thêm"; Action.Reference = txtMa.Text; Action.LuuThongTin(); this.Close(); }
private void BtnSua_ItemClick(object sender, ItemClickEventArgs e) { int rowIndex = gvMain.FocusedRowHandle; DataRow fHH = BUS_HangHoa.TimHH(gvMain.GetRowCellValue(rowIndex, "Product_ID").ToString()); string _Product_ID = fHH.Field <string>("Product_ID"); string _Product_Name = fHH.Field <string>("Product_Name"); int _Product_Type_ID = fHH.Field <int>("Product_Type_ID"); string _Product_Group_ID = fHH.Field <string>("Product_Group_ID"); string _Provider_ID = fHH.Field <string>("Provider_ID"); string _Unit = fHH.Field <string>("Unit"); string _Photo = fHH.Field <string>("_Photo"); decimal _Org_Price = fHH.Field <decimal>("Org_Price"); decimal _Sale_Price = fHH.Field <decimal>("Sale_Price"); decimal _Retail_Price = fHH.Field <decimal>("Retail_Price"); string _Customer_ID = fHH.Field <string>("Customer_ID"); string _Customer_Name = fHH.Field <string>("Customer_Name"); decimal _MinStock = fHH.Field <decimal>("MinStock"); bool _Active = fHH.Field <bool>("Active"); CHangHoa hh = new CHangHoa { Product_ID = _Product_ID, Product_Name = _Product_Name, Product_Type_ID = _Product_Type_ID, Product_Group_ID = _Product_Group_ID, Provider_ID = _Provider_ID, Unit = _Unit, Photo = _Photo == null?"":_Photo, Org_Price = float.Parse(_Org_Price.ToString()), Sale_Price = float.Parse(_Sale_Price.ToString()), Retail_Price = float.Parse(_Retail_Price.ToString()), Customer_ID = _Customer_ID, Customer_Name = _Customer_Name, MinStock = (int)_MinStock, Active = _Active }; fThemHangHoa sua = new fThemHangHoa(false, hh, LoadData); sua.ShowDialog(); }
public fThemHangHoa(bool isAdd = true, CHangHoa hh = null, fHangHoa.sendMessage send = null) { InitializeComponent(); if (isAdd == false && hh == null) { XtraMessageBox.Show("ERROR : Dữ liệu không được cung cấp để thực hiện hành động !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } if (isAdd == true) { table = BUS_HangHoa.LayHangHoa(); Text = "Thêm Hàng hóa"; } else { editHH = hh; Text = "Sửa thông tin Hàng hóa"; } add = isAdd; sendHH = send; Init(); }
public void ThemHangHoa(CHangHoa hh) { Provider dao = new Provider(); try { dao.Connect(); string sql = "PRODUCT_Insert_New"; CommandType type = CommandType.StoredProcedure; dao.ExeCuteNonQuery(type, sql, new SqlParameter { ParameterName = "@Product_ID", Value = hh.Product_ID }, new SqlParameter { ParameterName = "@Product_Name", Value = hh.Product_Name }, new SqlParameter { ParameterName = "@Product_Type_ID", Value = hh.Product_Type_ID }, new SqlParameter { ParameterName = "@Product_Group_ID", Value = hh.Product_Group_ID }, new SqlParameter { ParameterName = "@Provider_ID", Value = hh.Provider_ID }, new SqlParameter { ParameterName = "@Barcode", Value = hh.Barcode }, new SqlParameter { ParameterName = "@Unit", Value = hh.Unit }, new SqlParameter { ParameterName = "@Photo", Value = hh.Photo }, new SqlParameter { ParameterName = "@Org_Price", Value = hh.Org_Price }, new SqlParameter { ParameterName = "@Sale_Price", Value = hh.Sale_Price }, new SqlParameter { ParameterName = "@Retail_Price", Value = hh.Retail_Price }, new SqlParameter { ParameterName = "@Customer_ID", Value = hh.Customer_ID }, new SqlParameter { ParameterName = "@Customer_Name", Value = hh.Customer_Name }, new SqlParameter { ParameterName = "@MinStock", Value = hh.MinStock }, new SqlParameter { ParameterName = "@UserID", Value = hh.UserID }, new SqlParameter { ParameterName = "@Active", Value = hh.Active } ); } catch (SqlException ex) { throw ex; } finally { dao.DisConnect(); } }