public ActionResult SaveZhixing(int QuotationId, int?SeqNo, string QuotationType, int ProjectId, int SupplierId) { if (QuotationId == 0) {//新增确认单 QuotationId = SaveQuotationMst(QuotationType, ProjectId, SupplierId); int seqNo = 1; var maxOne = db.Quotation_Zhixing_Dtl.Where(x => x.QuotationId == QuotationId) .OrderByDescending(x => x.SeqNO).Select(x => x.SeqNO).FirstOrDefault(); if (maxOne > 0) { seqNo = maxOne + 1; } Quotation_Zhixing_Dtl dtl = new Quotation_Zhixing_Dtl(); TryUpdateModel <Quotation_Zhixing_Dtl>(dtl); dtl.SeqNO = seqNo; dtl.QuotationId = QuotationId; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; db.Quotation_Zhixing_Dtl.Add(dtl); } else { Quotation_Zhixing_Dtl dtl = new Quotation_Zhixing_Dtl(); dtl = db.Quotation_Zhixing_Dtl.Find(QuotationId, SeqNo); TryUpdateModel <Quotation_Zhixing_Dtl>(dtl); } db.SaveChanges(); return(Json(new { QuotationId = QuotationId }));; }
public ActionResult FindZhixing(int QuotationId, int?SeqNo) { Quotation_Zhixing_Dtl dtl = new Quotation_Zhixing_Dtl(); if (QuotationId > 0) { dtl = db.Quotation_Zhixing_Dtl.Find(QuotationId, SeqNo); } return(Json(dtl, JsonRequestBehavior.AllowGet)); }
public ActionResult SaveZhixing(string jsonArr, string ProjectId, string SupplierId, string GroupId) { List <Quotation_Zhixing_Dtl> lst = JsonConvert.DeserializeObject <List <Quotation_Zhixing_Dtl> >(jsonArr); int QuotationId = SaveQuotationMst(GroupId, ProjectId, SupplierId, "Zhixing"); foreach (Quotation_Zhixing_Dtl dtl in lst) { if (dtl.QuotationId == 0 && dtl.SeqNO == 0) { int seqNo = 1; var maxOne = db.Quotation_Zhixing_Dtl.Where(x => x.QuotationId == QuotationId) .OrderByDescending(x => x.SeqNO).Select(x => x.SeqNO).FirstOrDefault(); if (maxOne > 0) { seqNo = maxOne + 1; } dtl.QuotationId = QuotationId; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; db.Quotation_Zhixing_Dtl.Add(dtl); db.SaveChanges(); } else { Quotation_Zhixing_Dtl findOne = db.Quotation_Zhixing_Dtl.Find(dtl.QuotationId, dtl.SeqNO); if (findOne != null) { findOne.AccountUnit = dtl.AccountUnit; findOne.Count = dtl.Count; findOne.UnitPrice = dtl.UnitPrice; findOne.Remark = dtl.Remark; } db.SaveChanges(); } } return(Json("")); }
public ActionResult QuotationGroupCopy(string SourceGroupId, string TargetGroupId, string ProjectId) { int seqNo = 0; //Biancheng List <Quotation_BianChengDto> bianchengList = quotationService.Quotation_BianChengCopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_BianChengDto dto in bianchengList) { Quotation_Biancheng_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Biancheng_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Biancheng", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Biancheng_Dtl.Add(dtl); } //ZhiXing seqNo = 0; List <Quotation_ZhiXingDto> zhixingList = quotationService.Quotation_ZhiXingCopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_ZhiXingDto dto in zhixingList) { Quotation_Zhixing_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Zhixing_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Zhixing", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Zhixing_Dtl.Add(dtl); } //Fuhe seqNo = 0; List <Quotation_FuHeDto> fuheList = quotationService.Quotation_FuHeCopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_FuHeDto dto in fuheList) { Quotation_Fuhe_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Fuhe_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Fuhe", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Fuhe_Dtl.Add(dtl); } //Yanjiu seqNo = 0; List <Quotation_YanJiuDto> yanjiuList = quotationService.Quotation_YanJiuCopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_YanJiuDto dto in yanjiuList) { Quotation_Yanjiu_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Yanjiu_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Yanjiu", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Yanjiu_Dtl.Add(dtl); } //Qita1 seqNo = 0; List <Quotation_QiTa1Dto> qita1List = quotationService.Quotation_QiTa1CopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_QiTa1Dto dto in qita1List) { Quotation_Qita1_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Qita1_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Qita1", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Qita1_Dtl.Add(dtl); } //Qita2 seqNo = 0; List <Quotation_QiTa2Dto> qita2List = quotationService.Quotation_QiTa2CopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_QiTa2Dto dto in qita2List) { Quotation_Qita2_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Qita2_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Qita2", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Qita2_Dtl.Add(dtl); } //Chezhan seqNo = 0; List <Quotation_CheZhanDto> chezhanList = quotationService.Quotation_ChezhanCopySearch(TargetGroupId, SourceGroupId); foreach (Quotation_CheZhanDto dto in chezhanList) { Quotation_Chezhan_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Chezhan_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.IndateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Chezhan", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Chezhan_Dtl.Add(dtl); } //Zhichi seqNo = 0; List <ZhiChi01Dto> zhichiList = quotationService.Quotation_ZhichiCopySearch(TargetGroupId, SourceGroupId); foreach (ZhiChi01Dto dto in zhichiList) { Quotation_Zhichi_Dtl dtl = AutoMapperHelper.MapTo <Quotation_Zhichi_Dtl>(dto); seqNo++; dtl.SeqNO = seqNo; dtl.InDateTime = DateTime.Now; dtl.InUserId = UserInfo.UserId; dtl.QuotationId = SaveQuotationMst("Zhichi", ProjectId, dto.SupplierId, TargetGroupId); db.Quotation_Zhichi_Dtl.Add(dtl); } db.SaveChanges(); return(Json("")); }