public string UpdateQuoteLog(QuoteLogViewModel model) { string resultofquery; using (var context = new SR_Log_DatabaseSQLEntities()) { ObjectParameter result = new ObjectParameter("result", typeof(int)); DateTime LastDateFollowup = Convert.ToDateTime("1/1/1753"); if (model.dtpLastDateFollowup != null) { LastDateFollowup = Convert.ToDateTime(model.dtpLastDateFollowup); } DateTime QADeadLineDateTime = Convert.ToDateTime("1/1/1753"); if (model.QADeadLineDateTime != null) { QADeadLineDateTime = Convert.ToDateTime(model.QADeadLineDateTime); } var quotelog = context.USP_TT_InsertUpdateQuote(model.BidDate, model.BiddingAs, model.BidTo, model.ProjectName, model.LastAddendumRecvd, model.Estimator , model.QuoteNumber, model.UID, model.Notes, model.EngineersEstimate, model.Division, model.MandetoryJobWalk, model.JobWalkDate, QADeadLineDateTime, model.QuoteStatus, LastDateFollowup, model.LastFollowupBy, model.FollowupNote, model.Email, "E", "", result).ToString(); resultofquery = Convert.ToString(result.Value); } return(resultofquery); }
public ActionResult EditQuote(string id) { SRLogRepository objdata = new SRLogRepository(); QuoteLogRepository _repos = new QuoteLogRepository(); int QuoteId = Convert.ToInt32(id); QuoteLogViewModel objcre = _repos.GetQuoteRecords(QuoteId); objcre.CustomerList = objdata.GetCustomer(); objcre.GroupUsersList = objdata.GetGroupUser(); bool bExistEstimator = false; foreach (var i in objcre.GroupUsersList) { if (i.UserName == objcre.Estimator) { bExistEstimator = true; } } if (bExistEstimator == false) { tblGroupUser g = new tblGroupUser(); g.UserName = objcre.Estimator; g.Userid = objcre.Estimator; g.Group_Name = ""; objcre.GroupUsersList.Add(g); } objcre.emailids = _repos.GetEmailInfo(); ViewBag.UpdateDisable = false; if (Convert.ToString(Session["SR_Log_ReadOnly"]) == "True" && Convert.ToString(Session["Bid_Log_ReadOnly"]) == "True") { ViewBag.UpdateDisable = true; } objcre.Id = QuoteId; ViewBag.UId = objcre.UID; ViewBag.QuoteId = objcre.Id; return(View("Create", objcre)); }
public ActionResult Create() { QuoteLogRepository _mainrepo = new QuoteLogRepository(); QuoteLogViewModel objcre = new QuoteLogViewModel(); // QuoteLogRepository objdata = new QuoteLogRepository(); SRLogRepository objdata = new SRLogRepository(); objcre.CustomerList = objdata.GetCustomer(); objcre.GroupUsersList = objdata.GetGroupUser(); objcre.emailids = _mainrepo.GetEmailInfo(); ViewBag.UpdateDisable = false; objcre.Id = 0; if (Convert.ToString(Session["SR_Log_ReadOnly"]) == "True" && Convert.ToString(Session["Bid_Log_ReadOnly"]) == "True") { ViewBag.UpdateDisable = true; } return(View(objcre)); }
public QuoteLogViewModel GetQuoteRecords(int Id) { QuoteLogViewModel vw = new QuoteLogViewModel(); using (var db = new SR_Log_DatabaseSQLEntities()) { var quptelist = (from b in db.tblQuoteLogs where b.Id == Id select b).ToList(); vw.BiddingAsIandC = false; vw.BiddingAsElectircal = false; vw.BiddingAsPrime = false; vw.BiddingAsUnKnown = false; vw.BiddingAsNotBidding = false; vw.BiddingAsNotQualified = false; vw.BiddingAsMechanical = false; foreach (var i in quptelist) { vw.BidDate = i.BidDate; string BiddingAs = i.BiddingAs; string[] arrBiddingAs = BiddingAs.Split('#'); foreach (string x in arrBiddingAs) { if (x == "0") { vw.BiddingAsIandC = true; } if (x == "1") { vw.BiddingAsElectircal = true; } if (x == "2") { vw.BiddingAsPrime = true; } if (x == "3") { vw.BiddingAsUnKnown = true; } if (x == "4") { vw.BiddingAsNotBidding = true; } if (x == "5") { vw.BiddingAsNotQualified = true; } if (x == "6") { vw.BiddingAsMechanical = true; } } if (i.Division == "Concord") { vw.DivisionConcord = true; } if (i.Division == "Hanford") { vw.DivisionHanford = true; } if (i.Division == "Sacramento") { vw.DivisionSacramento = true; } vw.ProjectName = i.ProjectName; vw.LastAddendumRecvd = i.LastAddendumRecvd; vw.QuoteNumber = i.QuoteNumber; vw.Estimator = i.Estimator; vw.EngineersEstimate = i.EngineersEstimate; vw.Notes = i.Notes; vw.MandetoryJobWalk = (i.MandetoryJobWalk == true ? true : false); vw.JobWalkDate = i.JobWalkDate; vw.BidTo = i.BidTo; vw.Id = i.Id; vw.UID = i.UID; vw.QADeadLineDateTime = i.QADeadLineDateTime; vw.QuoteStatus = i.QuoteStatus; vw.dtpLastDateFollowup = i.dtpLastDateFollowup; vw.LastFollowupBy = i.LastFollowupBy; vw.FollowupNote = i.FollowupNote; vw.Email = i.EmailAddress; } return(vw); } }
public ActionResult Create(QuoteLogViewModel model, FormCollection form) { QuoteLogRepository _repo = new QuoteLogRepository(); SRLogRepository objdata = new SRLogRepository(); ModelState.Remove("Id"); if (ModelState.IsValid) { SR_Log_DatabaseSQLEntities objdb1 = new SR_Log_DatabaseSQLEntities(); string hdnCustomer = ""; if (string.IsNullOrEmpty(form["hdnCustomer"]) == false) { hdnCustomer = Convert.ToString(form["hdnCustomer"]).ToUpper(); } else { hdnCustomer = Convert.ToString(form["hdnCustomer"]); } string hdnCustUpdate = Convert.ToString(form["hdnCustUpdate"]); if (!string.IsNullOrEmpty(hdnCustUpdate)) { //Add or Update Customer tblCustomer cu = (from cust in objdb1.tblCustomers where cust.CustomerName == hdnCustomer select cust).FirstOrDefault(); CommonFunctions c = new CommonFunctions(); if (cu == null) { tblCustomer custad = new tblCustomer(); custad.CustomerName = hdnCustomer; custad.DateAdded = c.GetCurrentDate(); custad.IsInActive = false; custad.Notes = null; objdb1.tblCustomers.Add(custad); objdb1.SaveChanges(); } } model.BidTo = ""; if (string.IsNullOrEmpty(form["hdnCustomer"]) == false) { model.BidTo = Convert.ToString(form["hdnCustomer"]).ToUpper(); } else { model.BidTo = Convert.ToString(form["hdnCustomer"]); } string strBidAs = ""; if (model.BiddingAsIandC == true) { strBidAs = "0#"; } if (model.BiddingAsElectircal == true) { strBidAs = strBidAs + "1#"; } if (model.BiddingAsPrime == true) { strBidAs = strBidAs + "2#"; } if (model.BiddingAsUnKnown == true) { strBidAs = strBidAs + "3#"; } if (model.BiddingAsNotBidding == true) { strBidAs = strBidAs + "4#"; } if (model.BiddingAsNotQualified == true) { strBidAs = strBidAs + "5#"; } if (model.BiddingAsMechanical == true) { strBidAs = strBidAs + "6#"; } model.BiddingAs = strBidAs; if (model.DivisionConcord == true) { model.Division = "Concord"; } else if (model.DivisionHanford == true) { model.Division = "Hanford"; } else if (model.DivisionSacramento == true) { model.Division = "Sacramento"; } if (string.IsNullOrEmpty(model.ProjectName) == false) { model.ProjectName = model.ProjectName.ToUpper(); } if (string.IsNullOrEmpty(model.QuoteStatus) == false) { model.QuoteStatus = model.QuoteStatus.ToUpper(); } if (string.IsNullOrEmpty(model.LastFollowupBy) == false) { model.LastFollowupBy = model.LastFollowupBy.ToUpper(); } if (string.IsNullOrEmpty(model.FollowupNote) == false) { model.FollowupNote = model.FollowupNote.ToUpper(); } if (string.IsNullOrEmpty(model.EngineersEstimate) == false) { model.EngineersEstimate = model.EngineersEstimate.ToUpper(); } if (string.IsNullOrEmpty(model.Notes) == false) { model.Notes = model.Notes.ToUpper(); } _repo.UpdateQuoteLog(model); ViewBag.UId = model.UID; ViewBag.ID = model.Id; string dtpLastDateFollowup = ""; if (model.dtpLastDateFollowup == null) { dtpLastDateFollowup = ""; } else { dtpLastDateFollowup = Convert.ToDateTime(model.dtpLastDateFollowup).ToString("MM-dd-yyyy"); } string bidDate = ""; if (model.BidDate == null) { bidDate = ""; } else { bidDate = Convert.ToDateTime(model.BidDate).ToString("MM-dd-yyyy"); } SendQuoteModifyMailSMTP(dtpLastDateFollowup, model.Email, model.BidTo, model.ProjectName, bidDate, model.QuoteStatus, model.LastFollowupBy, model.FollowupNote); var act = new ActivityRepository(); act.AddActivityLog(Convert.ToString(Session["User"]), "Update Quote", "Create", "Quote " + model.UID + " updated by user " + Convert.ToString(Session["User"]) + "."); ViewBag.Message = "Record Updated Successfully And Quote Modified Status Mail Sent Succesfully"; } //BidLogViewModel objcre = new BidLogViewModel(); objdata = new SRLogRepository(); model.CustomerList = objdata.GetCustomer(); model.GroupUsersList = objdata.GetGroupUser(); bool bExistEstimator = false; foreach (var i in model.GroupUsersList) { if (i.UserName == model.Estimator) { bExistEstimator = true; } } if (bExistEstimator == false) { tblGroupUser g = new tblGroupUser(); g.UserName = model.Estimator; g.Userid = model.Estimator; g.Group_Name = ""; model.GroupUsersList.Add(g); } ViewBag.UpdateDisable = false; if (Convert.ToString(Session["SR_Log_ReadOnly"]) == "True" && Convert.ToString(Session["Bid_Log_ReadOnly"]) == "True") { ViewBag.UpdateDisable = true; } model.emailids = _repo.GetEmailInfo(); return(View("Create", model)); }