public RedirectToRouteResult EditNewPOSupplier(string data, int index) { using (SSISdbEntities e = new SSISdbEntities()) { List <POFullDetail> poFullDetailsList = (List <POFullDetail>)Session["newPOList"]; POFullDetail item = poFullDetailsList.ElementAt(index); item.CompanyName = data; SupplierPriceList spl = e.SupplierPriceLists.Where(y => y.SupplierCode == item.CompanyName).FirstOrDefault(); item.UnitCost = spl.UnitCost; Session["newAdjList"] = poFullDetailsList; return(RedirectToAction("Purchase", "Store")); } }
public RedirectToRouteResult UpdateSupplierPriceList(String[] arrItemCodes, String[] arrStatus, String[] price) { try { Session["MaintenanceSuppliersPage"] = "2"; String supplierCode = Session["MaintenanceSupplierCode"].ToString(); if (arrItemCodes.Count() > 0 && arrStatus.Count() > 0 && price.Count() > 0) { using (SSISdbEntities e = new SSISdbEntities()) { DAL.SupplierPriceListRepositoryImpl dal = new DAL.SupplierPriceListRepositoryImpl(e); int index = 0; foreach (string s in arrItemCodes) { SupplierPriceList spl = e.SupplierPriceLists.Where(x => x.SupplierCode == supplierCode && x.ItemCode == s).FirstOrDefault(); spl.UnitCost = float.Parse(price[index]); if (arrStatus[index] == "true") { spl.Active = 1; } else { spl.Active = 0; } dal.UpdateSupplierPriceList(spl); index++; } e.SaveChanges(); } } else { Debug.Write("Empty input detected."); } } catch (FormatException fe) { Debug.WriteLine(fe.Message); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(RedirectToAction("Maintenance", "Store")); }
public bool UpdateSupplierPriceList(SupplierPriceList updateSupplierPriceList, bool newVer = false) { try { if (updateSupplierPriceList == null) { throw new ArgumentNullException("updateSupplierPriceList"); } using (var db = new HKSupplyContext()) { using (var dbTrans = db.Database.BeginTransaction()) { try { updateSupplierPriceList.IdSubVer += 1; if (newVer == true) { updateSupplierPriceList.IdVer += 1; updateSupplierPriceList.IdSubVer = 0; } updateSupplierPriceList.Timestamp = DateTime.Now; SupplierPriceListHistory supplierPriceListHistory = (SupplierPriceListHistory)updateSupplierPriceList; supplierPriceListHistory.User = GlobalSetting.LoggedUser.UserLogin; //Con esto marcaremos todo el objeto como modificado y actualizará todos los campos. //En este caso nos interesa porque la mayoría de los campos de supplier se pueden modificar db.Entry(updateSupplierPriceList).State = EntityState.Modified; db.SuppliersPriceListHistory.Add(supplierPriceListHistory); db.SaveChanges(); dbTrans.Commit(); return(true); } catch (SqlException sqlex) { dbTrans.Rollback(); for (int i = 0; i < sqlex.Errors.Count; i++) { _log.Error("Index #" + i + "\n" + "Message: " + sqlex.Errors[i].Message + "\n" + "Error Number: " + sqlex.Errors[i].Number + "\n" + "LineNumber: " + sqlex.Errors[i].LineNumber + "\n" + "Source: " + sqlex.Errors[i].Source + "\n" + "Procedure: " + sqlex.Errors[i].Procedure + "\n"); switch (sqlex.Errors[i].Number) { case -1: //connection broken case -2: //timeout throw new DBServerConnectionException(GlobalSetting.ResManager.GetString("DBServerConnectionError")); } } throw sqlex; } catch (Exception ex) { dbTrans.Rollback(); _log.Error(ex.Message, ex); throw ex; } } } } catch (ArgumentNullException anex) { _log.Error(anex.Message, anex); throw anex; } }
public bool NewSupplierPriceList(SupplierPriceList newSupplierPriceList) { try { if (newSupplierPriceList == null) { throw new ArgumentNullException("newSupplierPriceList"); } using (var db = new HKSupplyContext()) { using (var dbTrans = db.Database.BeginTransaction()) { try { var tmpSupplierPriceList = GetSupplierPriceList(newSupplierPriceList.IdItemBcn, newSupplierPriceList.IdSupplier); if (tmpSupplierPriceList != null) { throw new Exception("Supplier Price List already exist"); } newSupplierPriceList.IdVer = 1; newSupplierPriceList.IdSubVer = 0; newSupplierPriceList.Timestamp = DateTime.Now; SupplierPriceListHistory supplierPriceListHistory = (SupplierPriceListHistory)newSupplierPriceList; supplierPriceListHistory.User = GlobalSetting.LoggedUser.UserLogin; db.SuppliersPriceList.Add(newSupplierPriceList); db.SuppliersPriceListHistory.Add(supplierPriceListHistory); db.SaveChanges(); dbTrans.Commit(); return(true); } catch (SqlException sqlex) { dbTrans.Rollback(); for (int i = 0; i < sqlex.Errors.Count; i++) { _log.Error("Index #" + i + "\n" + "Message: " + sqlex.Errors[i].Message + "\n" + "Error Number: " + sqlex.Errors[i].Number + "\n" + "LineNumber: " + sqlex.Errors[i].LineNumber + "\n" + "Source: " + sqlex.Errors[i].Source + "\n" + "Procedure: " + sqlex.Errors[i].Procedure + "\n"); switch (sqlex.Errors[i].Number) { case -1: //connection broken case -2: //timeout throw new DBServerConnectionException(GlobalSetting.ResManager.GetString("DBServerConnectionError")); } } throw sqlex; } catch (Exception ex) { dbTrans.Rollback(); _log.Error(ex.Message, ex); throw ex; } } } } catch (ArgumentNullException anex) { _log.Error(anex.Message, anex); throw anex; } }
public void UpdateSupplierPriceList(SupplierPriceList supplierPriceList) { context.Entry(supplierPriceList).State = EntityState.Modified; }
public void DeleteSupplierPriceList(string supplierCode, string itemCode) { SupplierPriceList supplierPriceList = context.SupplierPriceLists.Where(x => x.SupplierCode == supplierCode && x.ItemCode == itemCode).First(); context.SupplierPriceLists.Remove(supplierPriceList); }
public void InsertSupplierPriceList(SupplierPriceList supplierPriceList) { context.SupplierPriceLists.Add(supplierPriceList); }