Exemple #1
0
 public int UpdateMBAnalysisInContract(ContractsAndMBAnalysisType obj, int itemID, int? contractID, int? mbAnalysisTypeID, int paymentTypeID, decimal price)
 {
     if ((contractID == null) && (mbAnalysisTypeID == null))
     {
         //ContractsAndMBAnalysisType obj = new ContractsAndMBAnalysisType();
         obj = db.ContractsAndMBAnalysisTypes.Where(o => o.ContractAndMBAnalysisTypeID == itemID).SingleOrDefault();
         //obj.ContractID = contractID;
         //obj.MBAnalysisTypeID = mbAnalysisID;
         obj.PaymentTypeID = paymentTypeID;
         obj.Price = price;
         obj.DateUpdate = DateTime.Now;
         obj.Suser = System.Web.Security.Membership.GetUser().ToString();
         //db.ContractsAndMBAnalysisTypes.Attach(obj);
         db.ObjectStateManager.ChangeObjectState(obj, EntityState.Modified);
         db.SaveChanges();
     }
     else
     {
         // ContractsAndMBAnalysisType obj = new ContractsAndMBAnalysisType();
         obj = db.ContractsAndMBAnalysisTypes.Where(o => o.ContractAndMBAnalysisTypeID == itemID).SingleOrDefault();
         obj.ContractID = contractID;
         obj.MBAnalysisTypeID = mbAnalysisTypeID;
         obj.PaymentTypeID = paymentTypeID;
         obj.Price = price;
         obj.DateUpdate = DateTime.Now;
         obj.Suser = System.Web.Security.Membership.GetUser().ToString();
         //db.ContractsAndMBAnalysisTypes.Attach(obj);
         db.ObjectStateManager.ChangeObjectState(obj, EntityState.Modified);
         db.SaveChanges();
     }
     return 0;
 }
Exemple #2
0
 public dbActionResult EditMBAnalysisInContract(ContractsAndMBAnalysisType obj)
 {
     try
     {
         obj.DateUpdate = DateTime.Now;
         obj.Suser = System.Web.Security.Membership.GetUser().ToString();
         db.ContractsAndMBAnalysisTypes.Attach(obj);
         db.ObjectStateManager.ChangeObjectState(obj, EntityState.Modified);
         db.SaveChanges();
         dbActionResult returnObj = new dbActionResult();
         returnObj.intResult = obj.ContractAndMBAnalysisTypeID;
         returnObj.exConcur = null;
         returnObj.exData = null;
         return (returnObj);
     }
     catch (OptimisticConcurrencyException ex)
     {
         dbActionResult returnObj = new dbActionResult();
         returnObj.intResult = -1;
         returnObj.exConcur = ex;
         returnObj.exData = null;
         return (returnObj);
     }
     catch (DataException ex)
     {
         dbActionResult returnObj = new dbActionResult();
         returnObj.intResult = -2;
         returnObj.exConcur = null;
         returnObj.exData = ex;
         return (returnObj);
     }
 }
Exemple #3
0
 public int AddMBAnalysisToContract(int ContractID, int MBAnalysisID, int PaymentTypeID, decimal Price)
 {
     try
     {
         ContractsAndMBAnalysisType obj = new ContractsAndMBAnalysisType();
         obj.ContractID = ContractID;
         obj.MBAnalysisTypeID = MBAnalysisID;
         obj.PaymentTypeID = PaymentTypeID;
         obj.Price = Price;
         obj.DateAdd = DateTime.Now;
         obj.DateUpdate = DateTime.Now;
         obj.Suser = System.Web.Security.Membership.GetUser().ToString();
         db.ContractsAndMBAnalysisTypes.AddObject(obj);
         db.ObjectStateManager.ChangeObjectState(obj, EntityState.Added);
         db.SaveChanges();
     }
     catch (DataException ex)
     {
         string temp = ex.Message + " Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору.";
     }
     //return obj.ContractAndMBAnalysisTypeID;
     return 0;
 }
 /// <summary>
 /// Create a new ContractsAndMBAnalysisType object.
 /// </summary>
 /// <param name="contractAndMBAnalysisTypeID">Initial value of the ContractAndMBAnalysisTypeID property.</param>
 public static ContractsAndMBAnalysisType CreateContractsAndMBAnalysisType(global::System.Int32 contractAndMBAnalysisTypeID)
 {
     ContractsAndMBAnalysisType contractsAndMBAnalysisType = new ContractsAndMBAnalysisType();
     contractsAndMBAnalysisType.ContractAndMBAnalysisTypeID = contractAndMBAnalysisTypeID;
     return contractsAndMBAnalysisType;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ContractsAndMBAnalysisTypes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContractsAndMBAnalysisTypes(ContractsAndMBAnalysisType contractsAndMBAnalysisType)
 {
     base.AddObject("ContractsAndMBAnalysisTypes", contractsAndMBAnalysisType);
 }
 public ActionResult PartialContractMbAnalysisEdit(ContractsAndMBAnalysisType obj)
 {
     if (ModelState.IsValid)
     {
         if (obj.ContractAndMBAnalysisTypeID == -1)
         {
             db.AddMBAnalysisToContract(int.Parse(obj.ContractID.ToString()), int.Parse(obj.MBAnalysisTypeID.ToString()), int.Parse(obj.PaymentTypeID.ToString()), decimal.Parse(obj.Price.ToString()));
         }
         else
         {
             db.EditMBAnalysisInContract(obj);
         }
         ModelState.Clear();
     }
     return RedirectToAction("EditContract", new { id = obj.ContractID, showAnalysis = 1 });
 }
 public ActionResult PartialContractMBAnalysisEdit(int contractMBAnalysisId = -1, int contractId = -1)
 {
     ContractsAndMBAnalysisType model = new ContractsAndMBAnalysisType();
     if (contractMBAnalysisId > 0)
     {
         model = dbm.ContractsAndMBAnalysisTypes.SingleOrDefault(o => o.ContractAndMBAnalysisTypeID == contractMBAnalysisId);
         var itemsAnalysis = db.GetMBAnalysisTypeListActive();
         List<SelectListItem> listAnalysis = new List<SelectListItem>();
         foreach (var item in itemsAnalysis)
         {
             listAnalysis.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.MBAnalysisTypeID.ToString() });
         }
         var selectAnalysis = new SelectList(listAnalysis, "Value", "Text", model.MBAnalysisTypeID);
         var itemsPaymentType = db.GetPaymentTypeList();
         List<SelectListItem> listPaymentType = new List<SelectListItem>();
         foreach (var item in itemsPaymentType)
         {
             listPaymentType.Add(new SelectListItem { Text = item.Description, Value = item.PaymentTypeID.ToString() });
         }
         var selectPaymentType = new SelectList(listPaymentType, "Value", "Text", model.PaymentTypeID );
         ViewData["selectAnalysis"] = selectAnalysis;
         ViewData["selectPaymentType"] = selectPaymentType;
         ViewData["titleText"] = "Редактирование стоимости анализа";
         ViewData["buttonText"] = "Сохранить";
     }
     else
     {
         model.ContractAndMBAnalysisTypeID = -1;
         model.ContractID = contractId;
         var itemsAnalysis = db.GetMBAnalysisTypeListActive();
         List<SelectListItem> listAnalysis = new List<SelectListItem>();
         foreach (var item in itemsAnalysis)
         {
             listAnalysis.Add(new SelectListItem { Text = item.DescriptionRus, Value = item.MBAnalysisTypeID.ToString() });
         }
         var selectAnalysis = new SelectList(listAnalysis, "Value", "Text");
         var itemsPaymentType = db.GetPaymentTypeList();
         List<SelectListItem> listPaymentType = new List<SelectListItem>();
         foreach (var item in itemsPaymentType)
         {
             listPaymentType.Add(new SelectListItem { Text = item.Description, Value = item.PaymentTypeID.ToString() });
         }
         var selectPaymentType = new SelectList(listPaymentType, "Value", "Text");
         ViewData["selectAnalysis"] = selectAnalysis;
         ViewData["selectPaymentType"] = selectPaymentType;
         ViewData["titleText"] = "Добавление нового анализа в контракт";
         ViewData["buttonText"] = "Добавить";
     }
     return PartialView("PartialContractMBAnalysisEdit", model);
 }
 public ActionResult CreateContractWithMBAnalysis(vwCreateContractWithMBAnalysis model, List<int> IDList, string[] PaymentTypeID, string[] Price)
 {
     for (int i = 0; i < IDList.Count; i++)
     {
         ContractsAndMBAnalysisType obj = new ContractsAndMBAnalysisType();
         obj = db.GetContractsAndMBAnalysisType(IDList[i]);
         db.UpdateMBAnalysisInContract(obj, IDList[i], null, null, int.Parse(PaymentTypeID[i]), decimal.Parse(Price[i]));
     }
     return RedirectToAction("Index", new { message = "Контракт " + "'" + model.ContractItem.Description + "' с регистрационным номером " + model.ContractItem.AccountNumber + " добавлен в систему." });
 }