public EProduct Insert(EProduct eProduct) { EProduct eResult = null; BSequence bSequence = new BSequence(); ESequence eSequence = new ESequence(eProduct); int correlative = 0; correlative = bSequence.GetCorrelative(eSequence); eProduct.CodeProduct = correlative.ToString("0000000000"); eProduct.Validar(); dProduct.Insert(eProduct); if (dProduct.ExistsPrimaryKey()) { Message = string.Format("El código de Producto '{0}' ya existe en el Sistema, no se puede crear el registro.", eProduct.CodeProduct); throw new Exception(Message); } if (dProduct.ExistsReference()) { Message = string.Format("Se intento grabar una llave foranea incorrecta '{0}', no se puede crear el registro.", eProduct.CodeProduct); throw new Exception(Message); } correlative++; eSequence.Correlative = correlative; bSequence.SetCorrelativo(eSequence); eResult = Select(eProduct); eProduct.Audit.Code = eResult.CodeProduct.ToString(); eProduct.Audit.TypeEvent = "Insert"; bAudit.Insert(eProduct.Audit); return(eResult); }
public void Delete(EProduct eProduct) { DaCommand command = new DaCommand("ProductDelete"); command.AddInParameter("@CodeProduct", DbType.String, eProduct.CodeProduct); ExecuteNonQuery(command); }
public DataRow Select(EProduct eProduct) { DaCommand command = new DaCommand("ProductSelect"); command.AddInParameter("@CodeProduct", DbType.String, eProduct.CodeProduct); return(ExecuteDataRow(command)); }
public static int UpdateProduct(EProduct Product) { SqlCommand com = new SqlCommand("ProductUpdate", Connection.Con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Pid", Product.ProductID); com.Parameters.AddWithValue("@Pname", Product.ProductName); com.Parameters.AddWithValue("@PcategoryID", Product.CategoryID); com.Parameters.AddWithValue("@Pprice", Product.Price); com.Parameters.AddWithValue("@Pstock", Product.Stock); com.Parameters.AddWithValue("@Pdescription", Product.Description); if (com.Connection.State != ConnectionState.Open) { com.Connection.Open(); } int effectedRow = com.ExecuteNonQuery(); com.Dispose(); com.Connection.Close(); return(effectedRow); }
public static void SaveDownloadingUser(EProduct ep, string ip, string name, string email) { Task.Run(() => { using (HttpClient hc = new HttpClient()) { var response = hc.GetAsync(IonConsts.SERVER + $"Ion/SaveDownloadingUser?ep={EProduct.DESIGNARSENAL}&ip={Uri.EscapeDataString(ip)}&name={Uri.EscapeDataString(name)}&email={Uri.EscapeDataString(email)}").Result; response.EnsureSuccessStatusCode(); } }); }
public void Delete(EProduct eProduct) { dProduct.Delete(eProduct); if (dProduct.ExistsReference()) { Message = string.Format("El Producte '{0}' tiene referencias en el Sistema, no se puede eliminar el registro.", eProduct.CodeProduct); throw new Exception(Message); } eProduct.Audit.TypeEvent = "Delete"; bAudit.Insert(eProduct.Audit); }
public void FillGrid() { List <ELBasket> basket = BLLBasket.GetBasket(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB BASKET PULLED"); } DataTable dt = new DataTable(); dt.Columns.Add("Ürün"); dt.Columns.Add("Miktar"); dt.Columns.Add("Fiyat"); dt.Columns.Add("Numara"); if (basket != null) { noteID.Visible = true; TextBoxNoteID.Visible = true; payementType.Visible = true; acceptButtonImage.Visible = true; welc.Text = "Hoşgeldin " + name + " ! Sepetin tam burada !!"; welc.Visible = true; foreach (ELBasket item in basket) { DataRow dr = dt.NewRow(); EProduct pro = (EProduct)BLLProduct.SelectProduct(item.productId); using (System.IO.StreamWriter file = new System.IO.StreamWriter(submittedFilePath, true)) { file.WriteLine("[" + DateTime.Now + "] DB PRODUCT DATA SELECTED"); } dr["Ürün"] = pro.ProductName; dr["Miktar"] = item.productCount; dr["Fiyat"] = item.productCount * pro.Price; dr["Numara"] = item.id; dt.Rows.Add(dr); } BasketGrid.DataSource = dt; BasketGrid.DataBind(); } else { welc.Text = "Sepetin şu an boş"; welc.Visible = true; noteID.Visible = false; TextBoxNoteID.Visible = false; payementType.Visible = false; acceptButtonImage.Visible = false; BasketGrid.DataSource = dt; BasketGrid.DataBind(); } }
public List <EProduct> Listar(int local, string tipo) { List <EProduct> lista = new List <EProduct>(); string sql = "SELECT PR.ProductId, PR.Name, PR.Description,PR.Price, PR.type, PR.Image, PR.OverallTime, P.PubId, P.Name as Local " + " FROM Products PR INNER JOIN Pubs P ON PR.PubId = P.PubId " + " Where P.PubId = @pubId AND type = @type "; try { using (SqlConnection con = new SqlConnection(cadenaconexion)) { con.Open(); using (SqlCommand com = new SqlCommand(sql, con)) { com.Parameters.Add(new SqlParameter("@pubId", local)); com.Parameters.Add(new SqlParameter("@type", tipo)); using (SqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { EProduct ve = new EProduct(); ve.id = Convert.ToInt32(dr[0]); ve.name = dr[1].ToString(); ve.description = dr[2].ToString(); ve.price = Convert.ToDouble(dr[3].ToString()); ve.type = dr[4].ToString(); ve.image = dr[5].ToString(); ve.overallTime = dr.GetTimeSpan(6); EPub oPub = new EPub() { id = Convert.ToInt32(dr[7]), name = dr[8].ToString() }; ve.pub = oPub; lista.Add(ve); } dr.Close(); } } } } catch (Exception ex) { throw ex; } return(lista); }
public int Delete(EProduct prod) { conn.Open(); string query = @"Delete from Product where ProdId=@ProdId"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@ProdId", prod.ProdId); int rows = cmd.ExecuteNonQuery(); return(rows); }
public Product GetProductByEnum(EProduct _eProduct) { foreach (Product product in m_AllProducts) { if (product.m_EProduct == _eProduct) { return(product); } } Debug.LogError("No Product: " + _eProduct.ToString() + " found"); return(null); }
public EProduct Update(EProduct eProduct) { EProduct eResult; eProduct.Validar(); dProduct.Update(eProduct); eProduct.Audit.TypeEvent = "Update"; bAudit.Insert(eProduct.Audit); eResult = Select(eProduct); return(eResult); }
public EProduct Select(EProduct eProduct) { EProduct eResult = null; DataRow dataRow; List <string> listColumns; dataRow = dProduct.Select(eProduct); if (dataRow != null) { listColumns = dataRow.GetColumns(); eResult = new EProduct(dataRow, listColumns); } return(eResult); }
public int Update(EProduct prod) { conn.Open(); string query = "Update Product set ProdName = @ProdName,ProdPrice = @ProdPrice,ProdDescription = @ProdDescription, CategoryId = @CategoryId WHERE ProdId = @ProdId "; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@ProdId", prod.ProdId); cmd.Parameters.AddWithValue("@ProdName", prod.ProdName); cmd.Parameters.AddWithValue("@ProdPrice", prod.ProdPrice); cmd.Parameters.AddWithValue("@ProdDescription", prod.ProdDecription); cmd.Parameters.AddWithValue("@CategoryId", prod.CategoryId); int rows = cmd.ExecuteNonQuery(); return(rows); }
public int Insert(EProduct prod) { conn.Open(); string query = "insert into Product(ProdName,ProdPrice,ProdDescription,ProdImagePath,CategoryId)values(@ProdName,@ProdPrice,@ProdDescription,@ProdImagePath,@CategoryId)"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@ProdName", prod.ProdName); cmd.Parameters.AddWithValue("@ProdPrice", prod.ProdPrice); cmd.Parameters.AddWithValue("@ProdDescription", prod.ProdDecription); cmd.Parameters.AddWithValue("@ProdImagePath", prod.ProdImagePath); cmd.Parameters.AddWithValue("@CategoryId", prod.CategoryId); int rows = cmd.ExecuteNonQuery(); return(rows); }
public void Select() { bool result = false; TransactionScope ts = new TransactionScope(); EProduct eProduct = new EProduct(); EProduct insertedProduct = new EProduct(); BProduct bProduct = new BProduct(); eProduct.DescriptionForSale = Aleatory.GetString(60); eProduct.DescriptionForStore = Aleatory.GetString(60); eProduct.Audit.UserRegister = Aleatory.GetString(8); insertedProduct = bProduct.Insert(eProduct); if (insertedProduct != null) { result = true; } Assert.IsTrue(result); }
public static bool CheckQueryingUser(EProduct ep, string hh64, string @as) { var query = new QueryedUser() { ep = ep, hh64 = hh64, @as = @as }; if (_cache.ContainsKey(query)) { var expires = _cache[query]; if (DateTime.Now <= expires) { return(true); } // expired _cache.Remove(query); } using (HttpClient hc = new HttpClient()) { try { var response = hc.GetAsync(IonConsts.SERVER + $"Ion/IsAuthorized?ep={query.ep}&hh64={query.hh64}&as={query.@as}").Result; response.EnsureSuccessStatusCode(); string res = response.Content.ReadAsStringAsync().Result; bool ok = res == "True"; if (ok) { _cache.Add(query, DateTime.Now.AddHours(5)); } return(ok); } catch (Exception) { return(false); } } }
//=====================================================GETS ABOVE===================================================== #region SaveAsync public async Task <string> SaveAsync(EProduct eProduct) { eProduct.ModificationDateUTC = DateTime.UtcNow; using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eProduct.Id)) { eProduct.Id = Guid.NewGuid().ToString(); eProduct.CreationDateUTC = DateTime.UtcNow; var e = await context.Products.AddAsync(eProduct); await context.SaveChangesAsync(); return(e.Entity.Id); } else { var e = context.Products.Update(eProduct); await context.SaveChangesAsync(); return(e.Entity.Id); } }
public void Update(EProduct eProduct) { DaCommand command = new DaCommand("ProductUpdate"); command.AddInParameter("@CodeProduct", DbType.String, eProduct.CodeProduct); command.AddInParameter("@CodeProductLine", DbType.String, eProduct.CodeProductLine); command.AddInParameter("@CodeProductFamily", DbType.String, eProduct.CodeProductFamily); command.AddInParameter("@CodeProductSubFamily", DbType.String, eProduct.CodeProductSubFamily); command.AddInParameter("@CodeProductLevel", DbType.String, eProduct.CodeProductLevel); command.AddInParameter("@CodeProductLevelTwo", DbType.String, eProduct.CodeProductLevelTwo); command.AddInParameter("@CodeProductType", DbType.String, eProduct.CodeProductType); command.AddInParameter("@CodeProductGroup", DbType.String, eProduct.CodeProductGroup); command.AddInParameter("@CodeProductBrand", DbType.String, eProduct.CodeProductBrand); command.AddInParameter("@CodeProductUnitMeasure", DbType.String, eProduct.CodeProductUnitMeasure); command.AddInParameter("@CodeProductModel", DbType.String, eProduct.CodeProductModel); command.AddInParameter("@CodeMoney", DbType.String, eProduct.CodeMoney); command.AddInParameter("@CodeProductRecet", DbType.String, eProduct.CodeProductRecet); command.AddInParameter("@CodeSunatProductTaxRV", DbType.String, eProduct.CodeSunatProductTaxRV); command.AddInParameter("@CodeSunatProductTaxRC", DbType.String, eProduct.CodeSunatProductTaxRC); command.AddInParameter("@UseRecet", DbType.Boolean, eProduct.UseRecet); command.AddInParameter("@CodeBar", DbType.String, eProduct.CodeBar); command.AddInParameter("@CodeIntern", DbType.String, eProduct.CodeIntern); command.AddInParameter("@DescriptionForStore", DbType.String, eProduct.DescriptionForStore); command.AddInParameter("@DescriptionForSale", DbType.String, eProduct.DescriptionForSale); command.AddInParameter("@DescriptionShortForStore", DbType.String, eProduct.DescriptionShortForStore); command.AddInParameter("@PriceCostMoneyNational", DbType.Decimal, eProduct.PriceCostMoneyNational); command.AddInParameter("@PriceCostMoneyForeign", DbType.Decimal, eProduct.PriceCostMoneyForeign); command.AddInParameter("@PriceSaleMoneyNational", DbType.Decimal, eProduct.PriceSaleMoneyNational); command.AddInParameter("@PriceSaleMoneyForeign", DbType.Decimal, eProduct.PriceSaleMoneyForeign); command.AddInParameter("@PriceCostAverage", DbType.Decimal, eProduct.PriceCostAverage); command.AddInParameter("@ActiveForSale", DbType.Boolean, eProduct.ActiveForSale); command.AddInParameter("@ActiveForBuy", DbType.Boolean, eProduct.ActiveForBuy); command.AddInParameter("@StockMinimun", DbType.Decimal, eProduct.StockMinimun); command.AddInParameter("@StockMaximun", DbType.Decimal, eProduct.StockMaximun); command.AddInParameter("@ValidateStock", DbType.Boolean, eProduct.ValidateStock); command.AddInParameter("@ValidateStock", DbType.Boolean, eProduct.ValidateStock); ExecuteNonQuery(command); }
public static int UpdateProduct(EProduct Product) { return(FProduct.UpdateProduct(Product)); }