protected void btnAdd_Click(object sender, EventArgs e) { LineItemDAL dal = new LineItemDAL(); string name = string.Empty; //if (string.Equals(Utility.GetSelectedText(ddlProjectAdd), "材料", StringComparison.OrdinalIgnoreCase) || string.Equals(Utility.GetSelectedText(ddlProjectAdd), "成品", StringComparison.OrdinalIgnoreCase)) //{ name = Utility.GetSelectedText(ddlProductNameAdd); //} LineItem item = new LineItem() { Intro = txtIntroAdd.Text, Name = name, Project = Utility.GetSelectedText(ddlProjectAdd), Quantity = !string.IsNullOrEmpty(txtQtyAdd.Text) ? double.Parse(txtQtyAdd.Text) : 0, Remark = txtRemarkAdd.Text, SourceId = SourceId, SourceType = SourceType, Spec = txtSpecAdd.Text, Unit = Utility.GetSelectedText(ddlUnitAdd), UnitPrice = !string.IsNullOrEmpty(txtUnitPriceAdd.Text) ? double.Parse(txtUnitPriceAdd.Text) : 0 }; dal.AddLineItem(item); dal.Save(); BindControl(); SetFocus(btnFocus); }
protected void btnImport_Click(object sender, EventArgs e) { SettlementDAL dal = new SettlementDAL(); LineItemDAL lDal = new LineItemDAL(); var settlement = dal.GetSettlementById(StId); StringBuilder sb = new StringBuilder(256); List <LineItem> lineItems = new List <LineItem>(); foreach (ListItem item in cblDeliveryList.Items) { if (item.Selected) { sb.Append(item.Text).Append("|"); lineItems.AddRange(lDal.GetLineItemsBySource(int.Parse(item.Value), SysConst.SourceTypeDelivery)); } } settlement.DeliveryList = sb.ToString(); dal.Save(); var dbItems = lDal.GetLineItemsBySource(this.StId, SysConst.SourceTypeSettlement); foreach (var item in dbItems) { lDal.DeleteItem(item.LineItem_Id); } foreach (var item in lineItems) { LineItem li = new LineItem() { Intro = item.Intro, Name = item.Name, OriginNo = item.OriginNo, Project = item.Project, Quantity = item.Quantity, Remark = item.Remark, SourceId = this.StId, SourceType = SysConst.SourceTypeSettlement, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDal.AddLineItem(li); } lDal.Save(); UIUtility.BindUserControl(LineItemsControl1, SysConst.SourceTypeSettlement, StId); }
protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e) { LineItemDAL dal = new LineItemDAL(); if (e.CommandName == "Save") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; TextBox txtIntro = e.Item.FindControl("txtIntro") as TextBox; TextBox txtProductName = e.Item.FindControl("txtProductName") as TextBox; TextBox txtSpec = e.Item.FindControl("txtSpec") as TextBox; TextBox txtUnit = e.Item.FindControl("txtUnit") as TextBox; TextBox txtPrice = e.Item.FindControl("txtPrice") as TextBox; TextBox txtQty = e.Item.FindControl("txtQty") as TextBox; TextBox txtRemark = e.Item.FindControl("txtRemark") as TextBox; var lineItem = dal.GetLineItemById(int.Parse(hdId.Value)); lineItem.Intro = txtIntro.Text; lineItem.Name = txtProductName.Text; lineItem.Spec = txtSpec.Text; lineItem.Unit = txtUnit.Text; lineItem.UnitPrice = !string.IsNullOrEmpty(txtPrice.Text) ? double.Parse(txtPrice.Text) : 0; lineItem.Quantity = !string.IsNullOrEmpty(txtQty.Text) ? double.Parse(txtQty.Text) : 0; lineItem.Remark = txtRemark.Text; dal.Save(); } if (e.CommandName == "Delete") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; dal.DeleteItem(int.Parse(hdId.Value)); } BindControl(); if (UpdateAmount != null) { UpdateAmount(SourceType, SourceId); } SetFocus(source); }
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 cblDeliveryList_SelectedIndexChanged(object sender, EventArgs e) { List <LineItem> items = new List <LineItem>(); LineItemDAL dal = new LineItemDAL(); foreach (ListItem listItem in cblDeliveryList.Items) { if (listItem.Selected) { var del = new DeliveryDAL().GetDeliveryByNo(listItem.Text); var delItems = dal.GetLineItemsBySource(del.Delivery_Id, SysConst.SourceTypeDelivery); foreach (var delItem in delItems) { items.Add(new LineItem() { Intro = delItem.Intro, Name = delItem.Name, OriginNo = listItem.Text, Project = delItem.Project, Quantity = delItem.Quantity, Remark = delItem.Remark, SourceId = StId, SourceType = SysConst.SourceTypeSettlement, Spec = delItem.Spec, Unit = delItem.Unit, UnitPrice = delItem.UnitPrice }); } } else { var lineItemsOfSt = dal.GetLineItemsBySource(StId, SysConst.SourceTypeSettlement); foreach (var item in lineItemsOfSt) { if (item.OriginNo == listItem.Text) { dal.DeleteItem(item.LineItem_Id); } } } } foreach (var item in items) { dal.AddLineItem(item); } dal.Save(); //save list StringBuilder sb = new StringBuilder(); for (int i = 0; i < cblDeliveryList.Items.Count; i++) { if (cblDeliveryList.Items[i].Selected) { sb.Append(cblDeliveryList.Items[i].Text).Append("|"); } } var stDAL = new SettlementDAL(); var st = stDAL.GetSettlementByNo(StNo); st.DeliveryList = sb.ToString(); stDAL.Save(); UIUtility.BindUserControl(LineItemsControl1, SysConst.SourceTypeSettlement, StId); }
protected void rpEnqList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "GenerateOrder" && (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)) { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; Enquiry enq = new EnquiryDAL().GetEnquiryById(int.Parse(hdId.Value)); OrderDAL dal = new OrderDAL(); var order = dal.GetOrderByEnq(enq.Enquiry_No); if (order != null) { ClientScript.RegisterClientScriptBlock(this.GetType(), "generateorder", string.Format("<script>window.open('OrderForm.aspx?ordid={0}&ordno={1}&sourcetype=E&sourceno={2}')</script>", order.Order_Id, order.Order_No, enq.Enquiry_No)); return; } SeedDAL sdal = new SeedDAL(); LineItemDAL lDAL = new LineItemDAL(); var no = sdal.GetNoByTableName(SysConst.TableOrder, SysConst.SuffixOrder); var enqItems = lDAL.GetLineItemsBySource(enq.Enquiry_Id, SysConst.SourceTypeEnquiry); Order ord = new Order(); ord.SourceType = SysConst.SourceTypeEnquiry; ord.SourceNo = enq.Enquiry_No; ord.Order_No = no; ord.Status = FirstStatusConsts.Order; ord.CreatedDate = DateTime.Now; ord.CustomerAddress = enq.CustomerAddress; ord.CustomerCompanyName = enq.CustomerCompanyName; ord.CustomerContactName = enq.CustomerContactName; ord.CustomerEmail = enq.CustomerEmail; ord.CustomerOthers = enq.CustomerOthers; ord.CustomerPhone1 = enq.CustomerPhone1; ord.CustomerPhone2 = enq.CustomerPhone2; ord.CustomerQQ = enq.CustomerQQ; ord.IsSampleProvidedToCustomer = enq.IsSampleProvidedToCustomer; ord.IsCustomerProvideSample = enq.IsCustomerProvideSample; ord.IsCustomerProvideImage = enq.IsCustomerProvideImage; ord.IsSurveyNeeded = enq.IsSurveyNeeded; ord.SurveyType = enq.SurveyType; ord.SurveyIntro = enq.SurveyIntro; ord.IsCADRefinementNeeded = enq.IsCADRefinementNeeded; ord.CADRefinementIntro = enq.CADRefinementIntro; ord.IsCADNeedCustomerConfirmation = enq.IsCADNeedCustomerConfirmation; ord.DeliveryType = enq.DeliveryType; ord.DeliveryIntro = enq.DeliveryIntro; ord.DeliveryToAddress = enq.DeliveryToAddress; ord.IsInstallProvided = enq.IsInstallProvided; ord.InstallType = string.IsNullOrEmpty(enq.InstallType) ? string.Empty : enq.InstallType; ord.InstallIntro = enq.InstallIntro; ord.EnqNo = enq.Enquiry_No; ord.IsActive = true; dal.AddOrder(ord); dal.Save(); //intro //intro Utility.AddDefault(ord.Order_No, SysConst.SourceTypeOrder, FooterConsts.Order); //item foreach (var item in enqItems) { LineItem newItem = new LineItem() { Intro = item.Intro, Name = item.Name, Project = item.Project, Quantity = item.Quantity, Remark = item.Remark, SourceId = ord.Order_Id, SourceType = SysConst.SourceTypeOrder, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDAL.AddLineItem(newItem); } lDAL.Save(); ClientScript.RegisterClientScriptBlock(this.GetType(), "generateorder", string.Format("<script>window.open('OrderForm.aspx?ordid={0}&ordno={1}&sourcetype=E&sourceno={2}')</script>", ord.Order_Id, ord.Order_No, enq.Enquiry_No)); } else if (e.CommandName == "Delete" && (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)) { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; new EnquiryDAL().Delete(int.Parse(hdId.Value)); Utility.BindDataToRepeater(rpEnqList, GetEnquiryList()); } else { SetSorting(e); if (!string.IsNullOrWhiteSpace(SortOrder)) { Utility.BindDataToRepeater(rpEnqList, GetEnquiryList().Sort(string.Format("{0} {1}", e.CommandName, SortOrder))); } } }
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)); }
protected void btnCreateSurvey_Click(object sender, EventArgs e) { //get no SeedDAL sdal = new SeedDAL(); string no = sdal.GetNoByTableName(SysConst.TableSurvey, SysConst.SuffixSuvey); //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; string surveyIntro = string.Empty; string enqNo = string.Empty; List <LineItem> items = new List <LineItem>(); int sourceId = -1; 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; surveyIntro = enq.SurveyIntro; enqNo = SourceNo; sourceId = enq.Enquiry_Id; //update enq status enq.Status = "申请测量"; enqDAL.Save(); } if (string.Equals(SourceType, SysConst.SourceTypeSalesOrder, StringComparison.OrdinalIgnoreCase)) { OrderDAL soDAL = new OrderDAL(); var so = soDAL.GetOrderByNo(SourceNo); 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; surveyIntro = so.SurveyIntro; enqNo = so.EnqNo; sourceId = so.Order_Id; //update ord status so.Status = "申请测量"; soDAL.Save(); } //new refine SurveyDAL dal = new SurveyDAL(); Survey survey = new Survey() { Survey_No = no, Status = FirstStatusConsts.Survey, 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, SurveyIntro = surveyIntro, EnqNo = enqNo }; dal.AddSurvey(survey); 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 = survey.Survey_Id, SourceType = SysConst.SourceTypeSurvey, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDAL.AddLineItem(target); } lDAL.Save(); int svid = survey.Survey_Id; string svno = survey.Survey_No; string url = Page.ResolveUrl(string.Format("~/SurveyForm.aspx?svid={0}&svno={1}&sourcetype={2}&sourceno={3}", svid, svno, SourceType, SourceNo)); string script = string.Format("<script>window.open('{0}')</script>", url); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createsuvey", script); BindControl(); SetFocus(btnCreateSurvey); }
public static Order GenerateOrder(Quotation quote) { Order ord = new Order(); SeedDAL sdal = new SeedDAL(); var ordNo = sdal.GetNoByTableName(SysConst.TableOrder, SysConst.SuffixOrder); ord.Order_No = ordNo; ord.SourceNo = quote.Quotation_No; ord.SourceType = SysConst.SourceTypeQuote; ord.CADRefinementIntro = quote.CADRefinementIntro; ord.CreatedDate = quote.CreatedDate; ord.CustomerAddress = quote.CustomerAddress; ord.CustomerCompanyName = quote.CustomerCompanyName; ord.CustomerContactName = quote.CustomerContactName; ord.CustomerEmail = quote.CustomerEmail; ord.CustomerOthers = quote.CustomerOthers; ord.CustomerPhone1 = quote.CustomerPhone1; ord.CustomerPhone2 = quote.CustomerPhone2; ord.CustomerQQ = quote.CustomerQQ; ord.DeliveryIntro = quote.DeliveryIntro; ord.DeliveryToAddress = quote.DeliveryToAddress; ord.DeliveryType = quote.DeliveryType; ord.InstallIntro = quote.InstallIntro; ord.InstallType = string.IsNullOrEmpty(quote.InstallType) ? string.Empty : quote.InstallType; ord.IsCADNeedCustomerConfirmation = quote.IsCADNeedCustomerConfirmation; ord.IsCADRefinementNeeded = quote.IsCADRefinementNeeded; ord.IsCustomerProvideImage = quote.IsCustomerProvideImage; ord.IsCustomerProvideSample = quote.IsCustomerProvideSample; ord.IsInstallProvided = quote.IsInstallProvided; ord.IsSampleProvidedToCustomer = quote.IsSampleProvidedToCustomer; ord.IsSurveyNeeded = quote.IsSurveyNeeded; ord.OrderIntro = quote.QuotationIntro; ord.OrderMan = quote.QuotationMan; ord.Status = FirstStatusConsts.Order; ord.SurveyIntro = quote.SurveyIntro; ord.SurveyType = quote.SurveyType; ord.EnqNo = quote.EnqNo; ord.IsActive = true; OrderDAL dal = new OrderDAL(); dal.AddOrder(ord); dal.Save(); LineItemDAL lDal = new LineItemDAL(); var items = lDal.GetLineItemsBySource(quote.Quotation_Id, SysConst.SourceTypeQuote); foreach (var item in items) { var newOrderItem = new LineItem() { Intro = item.Intro, Name = item.Name, Project = item.Project, Quantity = item.Quantity, Remark = item.Remark, SourceId = ord.Order_Id, SourceType = SysConst.SourceTypeOrder, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDal.AddLineItem(newOrderItem); } lDal.Save(); Utility.AddDefault(ord.Order_No, SysConst.SourceTypeOrder, FooterConsts.Order); return(ord); }
protected void btnGenerateOrder_Click(object sender, EventArgs e) { Enquiry enq = new EnquiryDAL().GetEnquiryByNo(GetQueryStringValue("enqno")); OrderDAL dal = new OrderDAL(); var order = dal.GetOrderByEnq(enq.Enquiry_No); if (order != null) { ClientScript.RegisterClientScriptBlock(this.GetType(), "generateorder", string.Format("<script>window.open('OrderForm.aspx?ordid={0}&ordno={1}&sourcetype=E&sourceno={2}')</script>", order.Order_Id, order.Order_No, enq.Enquiry_No)); return; } SeedDAL sdal = new SeedDAL(); LineItemDAL lDAL = new LineItemDAL(); var no = sdal.GetNoByTableName(SysConst.TableOrder, SysConst.SuffixOrder); var enqItems = lDAL.GetLineItemsBySource(enq.Enquiry_Id, SysConst.SourceTypeEnquiry); Order ord = new Order(); ord.SourceType = SysConst.SourceTypeEnquiry; ord.SourceNo = enq.Enquiry_No; ord.Order_No = no; ord.Status = FirstStatusConsts.Order; ord.CreatedDate = DateTime.Now; ord.CustomerAddress = enq.CustomerAddress; ord.CustomerCompanyName = enq.CustomerCompanyName; ord.CustomerContactName = enq.CustomerContactName; ord.CustomerEmail = enq.CustomerEmail; ord.CustomerOthers = enq.CustomerOthers; ord.CustomerPhone1 = enq.CustomerPhone1; ord.CustomerPhone2 = enq.CustomerPhone2; ord.CustomerQQ = enq.CustomerQQ; ord.IsSampleProvidedToCustomer = enq.IsSampleProvidedToCustomer; ord.IsCustomerProvideSample = enq.IsCustomerProvideSample; ord.IsCustomerProvideImage = enq.IsCustomerProvideImage; ord.IsSurveyNeeded = enq.IsSurveyNeeded; ord.SurveyType = enq.SurveyType; ord.SurveyIntro = enq.SurveyIntro; ord.IsCADRefinementNeeded = enq.IsCADRefinementNeeded; ord.CADRefinementIntro = enq.CADRefinementIntro; ord.IsCADNeedCustomerConfirmation = enq.IsCADNeedCustomerConfirmation; ord.DeliveryType = enq.DeliveryType; ord.DeliveryIntro = enq.DeliveryIntro; ord.DeliveryToAddress = enq.DeliveryToAddress; ord.IsInstallProvided = enq.IsInstallProvided; ord.InstallType = string.IsNullOrEmpty(enq.InstallType) ? string.Empty : enq.InstallType; ord.InstallIntro = enq.InstallIntro; ord.EnqNo = enq.Enquiry_No; ord.IsActive = true; dal.AddOrder(ord); dal.Save(); //intro Utility.AddDefault(ord.Order_No, SysConst.SourceTypeOrder, FooterConsts.Order); //item foreach (var item in enqItems) { LineItem newItem = new LineItem() { Intro = item.Intro, Name = item.Name, Project = item.Project, Quantity = item.Quantity, Remark = item.Remark, SourceId = ord.Order_Id, SourceType = SysConst.SourceTypeOrder, Spec = item.Spec, Unit = item.Unit, UnitPrice = item.UnitPrice }; lDAL.AddLineItem(newItem); } lDAL.Save(); ClientScript.RegisterClientScriptBlock(this.GetType(), "generateorder", string.Format("<script>window.open('OrderForm.aspx?ordid={0}&ordno={1}&sourcetype=E&sourceno={2}')</script>", ord.Order_Id, ord.Order_No, enq.Enquiry_No)); }
protected void btnImport_Click(object sender, EventArgs e) { DeliveryDAL dal = new DeliveryDAL(); LineItemDAL lDal = new LineItemDAL(); MachSummaryDAL mDAL = new MachSummaryDAL(); MachLookupDAL mlDAL = new MachLookupDAL(); var delivery = dal.GetDeliveryByNo(DeliveryNo); StringBuilder sb = new StringBuilder(256); List <MachSummary> machSummaryList = new List <MachSummary>(); foreach (ListItem item in cblMach.Items) { if (item.Selected) { sb.Append(item.Text).Append("|"); machSummaryList.AddRange(mDAL.GetSummaryByMachId(int.Parse(item.Value))); } } delivery.MachList = sb.ToString(); dal.Save(); var lineItems = lDal.GetLineItemsBySource(this.DeliveryId, SysConst.SourceTypeDelivery); foreach (var item in lineItems) { lDal.DeleteItem(item.LineItem_Id); } foreach (var item in machSummaryList) { var machLook = mlDAL.GetMachLookupByName(item.MachName); var lineItem = new LineItem(); lineItem.Intro = item.MachIntro; lineItem.Name = "加工"; lineItem.Project = item.MachName; lineItem.Quantity = item.Qty; lineItem.Remark = item.Remark; lineItem.SourceId = DeliveryId; lineItem.SourceType = SysConst.SourceTypeDelivery; lineItem.Spec = string.Empty; lineItem.Unit = item.Unit; if (string.Equals(item.Unit, "米")) { lineItem.UnitPrice = machLook.PriceM; } else if (string.Equals(item.Unit, "平方米")) { lineItem.UnitPrice = machLook.PriceM2; } else { lineItem.UnitPrice = machLook.PriceOther; } lDal.AddLineItem(lineItem); } lDal.Save(); UIUtility.BindUserControl(lineItemControl, SysConst.SourceTypeDelivery, DeliveryId); }