protected void btnCreateQuotation_Click(object sender, EventArgs e) { //get no SeedDAL sdal = new SeedDAL(); string no = sdal.GetNoByTableName(SysConst.TableNameQuotation, SysConst.SuffixQuotation); //get enqordman string enqOrdMan = string.Empty; string companyName = string.Empty; string contact = string.Empty; string address = string.Empty; string email = string.Empty; string qq = string.Empty; string phone1 = string.Empty; string phone2 = string.Empty; string other = string.Empty; bool isSampleToCustomer = false; bool isSampleFromCustomer = false; bool isCustomerProvideImg = false; bool isSurveyNeed = false; string surveyType = string.Empty; string surveyIntro = string.Empty; bool isCADRefineNeeded = false; string refineIntro = string.Empty; bool isCustomerConfirmNeeded = false; string deliveryType = string.Empty; string deliveryIntro = string.Empty; string deliveryAdd = string.Empty; bool isInstallProvided = false; string installType = string.Empty; string insallIntro = string.Empty; string enqNo = string.Empty; List <LineItem> items = new List <LineItem>(); int sourceId = -1; if (string.Equals(SourceType, SysConst.SourceTypeSalesOrder, StringComparison.OrdinalIgnoreCase)) { OrderDAL soDAL = new OrderDAL(); var so = soDAL.GetOrderByNo(SourceNo); so.Status = "申请报价"; soDAL.Save(); OnQuotationCreated(so.Status, EventArgs.Empty); enqOrdMan = so.OrderMan; companyName = so.CustomerCompanyName; contact = so.CustomerContactName; address = so.CustomerAddress; email = so.CustomerEmail; qq = so.CustomerQQ; phone1 = so.CustomerPhone1; phone2 = so.CustomerPhone2; other = so.CustomerOthers; isSampleToCustomer = so.IsSampleProvidedToCustomer; isSampleFromCustomer = so.IsCustomerProvideSample; isCustomerProvideImg = so.IsCustomerProvideImage; isSurveyNeed = so.IsSurveyNeeded; surveyType = so.SurveyType; surveyIntro = so.SurveyIntro; isCADRefineNeeded = so.IsCADRefinementNeeded; refineIntro = so.CADRefinementIntro; isCustomerConfirmNeeded = so.IsCADNeedCustomerConfirmation; deliveryType = so.DeliveryType; deliveryIntro = so.DeliveryIntro; deliveryAdd = so.DeliveryToAddress; isInstallProvided = so.IsInstallProvided; installType = string.IsNullOrEmpty(so.InstallType) ?string.Empty : so.InstallType; insallIntro = so.InstallIntro; enqNo = so.EnqNo; sourceId = so.Order_Id; } else if (string.Equals(SourceType, SysConst.SourceTypeEnquiry, StringComparison.OrdinalIgnoreCase)) { EnquiryDAL enqDAL = new EnquiryDAL(); var enq = enqDAL.GetEnquiryByNo(SourceNo); enqOrdMan = enq.EnqMan; companyName = enq.CustomerCompanyName; contact = enq.CustomerContactName; address = enq.CustomerAddress; email = enq.CustomerEmail; qq = enq.CustomerQQ; phone1 = enq.CustomerPhone1; phone2 = enq.CustomerPhone2; other = enq.CustomerOthers; isSampleToCustomer = enq.IsSampleProvidedToCustomer; isSampleFromCustomer = enq.IsCustomerProvideSample; isCustomerProvideImg = enq.IsCustomerProvideImage; isSurveyNeed = enq.IsSurveyNeeded; surveyType = enq.SurveyType; surveyIntro = enq.SurveyIntro; isCADRefineNeeded = enq.IsCADRefinementNeeded; refineIntro = enq.CADRefinementIntro; isCustomerConfirmNeeded = enq.IsCADNeedCustomerConfirmation; deliveryType = enq.DeliveryType; deliveryIntro = enq.DeliveryIntro; deliveryAdd = enq.DeliveryToAddress; isInstallProvided = enq.IsInstallProvided; installType = string.IsNullOrEmpty(enq.InstallType) ? string.Empty : enq.InstallType; insallIntro = enq.InstallIntro; enqNo = SourceNo; sourceId = enq.Enquiry_Id; //update enq status enq.Status = "申请报价"; enqDAL.Save(); } //new quote QuotationDAL dal = new QuotationDAL(); Quotation quote = new Quotation() { Quotation_No = no, Status = FirstStatusConsts.Quotation, EnqOrdMan = enqOrdMan, SourceType = SourceType, SourceNo = SourceNo, CreatedDate = DateTime.Now, CreatedAt = DateTime.Now, CreatedBy = SMSContext.Current.User.UserName, CustomerCompanyName = companyName, CustomerContactName = contact, CustomerAddress = address, CustomerEmail = email, CustomerQQ = qq, CustomerPhone1 = phone1, CustomerPhone2 = phone2, CustomerOthers = other, IsSampleProvidedToCustomer = isSampleToCustomer, IsCustomerProvideSample = isSampleFromCustomer, IsCustomerProvideImage = isCustomerProvideImg, IsSurveyNeeded = isSurveyNeed, SurveyType = surveyType, SurveyIntro = surveyIntro, IsCADRefinementNeeded = isCADRefineNeeded, CADRefinementIntro = refineIntro, IsCADNeedCustomerConfirmation = isCustomerConfirmNeeded, DeliveryType = deliveryType, DeliveryIntro = deliveryIntro, DeliveryToAddress = deliveryAdd, IsInstallProvided = isInstallProvided, InstallType = installType, InstallIntro = insallIntro, EnqNo = enqNo }; dal.AddQuote(quote); dal.Save(); LineItemDAL lDAL = new LineItemDAL(); items = lDAL.GetLineItemsBySource(sourceId, SourceType); foreach (var item in items) { LineItem target = new LineItem() { Intro = item.Intro, Name = item.Name, OriginNo = item.OriginNo, Project = item.Project, Quantity = item.Quantity, Remark = item.Remark, SourceId = quote.Quotation_Id, SourceType = SysConst.SourceTypeQuote, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDAL.AddLineItem(target); } lDAL.Save(); int quoId = quote.Quotation_Id; string quoNo = quote.Quotation_No; Utility.AddDefault(quote.Quotation_No, SysConst.SourceTypeQuote, FooterConsts.Quotation); string url = Page.ResolveUrl(string.Format("~/QuotationForm.aspx?quoid={0}&quono={1}&sourcetype={2}&sourceno={3}", quoId, quoNo, SourceType, SourceNo)); string script = string.Format("<script>window.open('{0}')</script>", url); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createquote", script); BindControl(); SetFocus(btnCreateQuotation); }
protected void btnCopy_Click(object sender, EventArgs e) { string quono = GetQueryStringValue("quono"); QuotationDAL dal = new QuotationDAL(); var sourceQuote = dal.GetQuoteByNo(quono); Quotation targetQuote = new Quotation(); SeedDAL sdal = new SeedDAL(); var quoteNo = sdal.GetNoByTableName(SysConst.TableNameQuotation, SysConst.SuffixQuotation); targetQuote.Quotation_No = quoteNo; targetQuote.SourceNo = sourceQuote.SourceNo; targetQuote.SourceType = sourceQuote.SourceType; targetQuote.CADRefinementIntro = sourceQuote.CADRefinementIntro; targetQuote.CreatedDate = sourceQuote.CreatedDate; targetQuote.CustomerAddress = sourceQuote.CustomerAddress; targetQuote.CustomerCompanyName = sourceQuote.CustomerCompanyName; targetQuote.CustomerContactName = sourceQuote.CustomerContactName; targetQuote.CustomerEmail = sourceQuote.CustomerEmail; targetQuote.CustomerOthers = sourceQuote.CustomerOthers; targetQuote.CustomerPhone1 = sourceQuote.CustomerPhone1; targetQuote.CustomerPhone2 = sourceQuote.CustomerPhone2; targetQuote.CustomerQQ = sourceQuote.CustomerQQ; targetQuote.DeliveryIntro = sourceQuote.DeliveryIntro; targetQuote.DeliveryToAddress = sourceQuote.DeliveryToAddress; targetQuote.DeliveryType = sourceQuote.DeliveryType; targetQuote.InstallIntro = sourceQuote.InstallIntro; targetQuote.InstallType = sourceQuote.InstallType; targetQuote.IsCADNeedCustomerConfirmation = sourceQuote.IsCADNeedCustomerConfirmation; targetQuote.IsCADRefinementNeeded = sourceQuote.IsCADRefinementNeeded; targetQuote.IsCustomerProvideImage = sourceQuote.IsCustomerProvideImage; targetQuote.IsCustomerProvideSample = sourceQuote.IsCustomerProvideSample; targetQuote.IsInstallProvided = sourceQuote.IsInstallProvided; targetQuote.IsSampleProvidedToCustomer = sourceQuote.IsSampleProvidedToCustomer; targetQuote.IsSurveyNeeded = sourceQuote.IsSurveyNeeded; targetQuote.QuotationIntro = sourceQuote.QuotationIntro; targetQuote.QuotationMan = sourceQuote.QuotationMan; targetQuote.Status = FirstStatusConsts.Order; targetQuote.SurveyIntro = sourceQuote.SurveyIntro; targetQuote.SurveyType = sourceQuote.SurveyType; dal.AddQuote(targetQuote); dal.Save(); LineItemDAL lDal = new LineItemDAL(); var items = lDal.GetLineItemsBySource(sourceQuote.Quotation_Id, SysConst.SourceTypeQuote); foreach (var item in items) { var targetQuoteItem = new LineItem() { Intro = item.Intro, Name = item.Name, Project = item.Project, Quantity = item.Quantity, Remark = item.Remark, SourceId = targetQuote.Quotation_Id, SourceType = SysConst.SourceTypeQuote, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDal.AddLineItem(targetQuoteItem); } lDal.Save(); //intro Utility.AddDefault(targetQuote.Quotation_No, SysConst.SourceTypeQuote, FooterConsts.Quotation); ClientScript.RegisterClientScriptBlock(this.GetType(), "copyquote", string.Format("<script>window.open('quotationform.aspx?quoid={0}&quono={1}&sourceno={2}&sourcetype={3}')</script>", targetQuote.Quotation_Id, targetQuote.Quotation_No, targetQuote.SourceNo, targetQuote.SourceType)); }