/// <summary> /// Exports data from file into database /// </summary> /// <returns></returns> public bool ExportToDb() { ErrorMessages.Clear(); try { List <T> list = this.ImportFile(); List <Product> active = CanonProduct.GetActiveProducts(); //go throw current active products and mark them as inactive if they are not in list foreach (Product act in active) { bool isFound = false; foreach (T product in list) { if (act.ProductCode == product.ProductCode) { isFound = true; break; } } if (!isFound) { CanonProduct.ActivateProduct(act.ProductCode, false); } } //import products from xls foreach (T product in list) { try { List <ImportErrorMessage> results = product.InsertUpdateProductWithPrice(); foreach (ImportErrorMessage res in results) { ErrorMessages.Add(res); } } catch (Exception ex) { //add message about error ErrorMessages.Add(new ImportErrorMessage("GeneralRecordImportError", new string[] { product.ProductName })); //into log WebVariables.Logger.Error(string.Format("File {0}, general import error", _filename), ex); } } } catch (Exception ex) { ErrorMessages.Add(new ImportErrorMessage("GeneralFileImportError")); //into log WebVariables.Logger.Error(string.Format("File {0} ", _filename), ex); return(false); } return(true); }
protected void gridPriceHistory_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { SessionManager.IsEditFormCreated = false; int keyToUpdate = int.Parse(e.Keys[0].ToString()); decimal newPrice = 0; if (e.NewValues["Price"] != null) { newPrice = (decimal)e.NewValues["Price"]; CanonProduct.UpdateRecommendedPrice(keyToUpdate, newPrice); } e.Cancel = true; gridPriceHistory.CancelEdit(); this.BindData(); } catch (Exception ex) { Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error); } }