private Model.PartItem MakePrint(Model.PsSheet ps) { int num = 0; if (ps.PrintNum > 0) { num = ps.PsNum * ProductNum / (ps.PrintNum); } else { num = ps.PsNum * ProductNum; } int colornum = ColorNum; Model.PartItem pips = new Model.PartItem(); pips.PartType = 4; string psname = ""; int pid = 4; decimal psprice = 0; if (colornum == 1) { psname = "黑白印工"; pid = 34; } if (colornum == 2) { psname = "黑白印工"; pid = 34; num = num * 2; } if (colornum == 4) { psname = "彩色印工"; } psprice = Model.C_ProcessPrice.GetProcessPrice(pid, num); Model.C_ProcessPrice cp = Model.C_ProcessPrice.GetById(pid); pips.Price = cp.SinglePrice1; pips.PartName = psname; pips.Name = psname; pips.Id = pid; pips.Num = num; pips.Money = psprice; pips.Remark = ps.PrintNum.ToString() + "拼"; return(pips); }
public bool AddProcess(int processid, int num) { Model.PartItem pi = new Model.PartItem(); pi.PartType = 8; pi.PartName = "后道工艺"; pi.Id = processid; Model.Process pro = Model.Process.GetDataById(processid); int extend = (int)(Part.PaperNum * 10 * pro.ExtendRatio); Part.PaperExtend += extend; AllExtendPaper += extend; pi.Name = pro.ProcessName; pi.Num = num; pi.Money = Model.C_ProcessPrice.GetProcessPrice(processid, num); Model.C_ProcessPrice cp = Model.C_ProcessPrice.GetById(processid); pi.Price = cp.SinglePrice1; pi.Remark = "放张数:" + extend.ToString(); AllItem.Add(pi); return(true); }
private Model.PartItem MakeOpen(Model.PsSheet ps) { int colornum = ColorNum; Model.PartItem pips = new Model.PartItem(); pips.PartType = 3; string psname = ""; int pid = 3; decimal psprice = 0; pips.Num = 1; if (colornum == 1) { psname = "黑白开机"; pid = 33; } if (colornum == 2) { psname = "黑白开机"; pips.Num = 2; pid = 33; } if (colornum == 4) { psname = "彩色开机"; } pips.Num = pips.Num * ps.PsNum; psprice = Model.C_ProcessPrice.GetProcessPrice(pid, 1); pips.PartName = psname; pips.Name = psname; pips.Id = pid; pips.Price = psprice; pips.Money = pips.Num * pips.Price; pips.Remark = ps.PrintNum.ToString() + "拼"; return(pips); }
private Model.PartItem MakePs(Model.PsSheet ps) { int colornum = ColorNum; Model.PartItem pips = new Model.PartItem(); pips.PartType = 2; string psname = ""; decimal psprice = 0; pips.Num = colornum * ps.PsNum; if (colornum == 1) { psname = "黑白版纸"; psprice = (decimal)14.1; pips.PartType = 1; } if (colornum == 2) { psname = "双套色版纸"; psprice = (decimal)14.1; pips.PartType = 1; } if (colornum == 4) { psname = "彩色版纸"; psprice = (decimal)13.3; pips.PartType = 2; } pips.PartName = psname; pips.Name = ps.PsKaidu.ToString() + "开" + psname; pips.Id = colornum; pips.Price = psprice; pips.Money = pips.Num * pips.Price; pips.Remark = ((Model.PsMode)ps.PrintNum).ToString(); return(pips); }
public bool MakePart() { #region 基础计算; bool result = true; if (!CheckPart()) { ProductType = -1; return(false); } Model.Tree cutree = Model.Common.PaperCut; Paper = cutree.GetPaper(Product.Length, Product.Width); Ps = cutree.GetPs(Product.Length, Product.Width); CutPaper = cutree.GetCutSize(Product.Length, Product.Width); int NumPrePage = 1; int calpage = PageNum; #region 计算用纸数量; if (PageNum % 2 == 1) { calpage = PageNum + 1; if (PageNum > 2) { PageNum = calpage; } } NumPrePage = calpage / 2; Part.PaperNum = NumPrePage * ProductNum / CutPaper.Kaidu; if (!PaperSource) { Model.PartItem pi = new Model.PartItem(); pi.PartType = 0; pi.PartName = "纸张"; pi.Id = PaperName.Id; pi.Name = PaperName.Name; pi.Price = Model.Paper_Store.GetPaperById(PaperName.Id).UnitPrice; pi.Num = Part.PaperNum; pi.Money = pi.Price * pi.Num; pi.Remark = PaperName.Name.Substring(0, 2) + CutPaper.Kaidu.ToString() + "开"; AllItem.Add(pi); } else { Part.PaperName = "来料加工"; Part.PaperId = 0; } #endregion if (ColorNum <= 0) { return(true); } if (Ps.Kaidu > 2 && CutPaper.Kaidu >= 12) { Ps.Kaidu = 2; } //计算2开印刷的情况; Model.PsSheet Sheet2 = new Model.PsSheet(Ps.Kaidu, CutPaper.Kaidu, PageNum); Model.PsSheet pstemp = Sheet2; decimal totalprice2 = 0; while (pstemp != null) { Model.PartItem pips = MakePs(pstemp); Model.PartItem piprint = MakePrint(pstemp); Model.PartItem piopen = MakeOpen(pstemp); totalprice2 += pips.Money; totalprice2 += piprint.Money; totalprice2 += piopen.Money; pips.Id += 20; piopen.Id += 20; piprint.Id += 20; AllItem.Add(pips); AllItem.Add(piprint); AllItem.Add(piopen); pstemp = pstemp.Next; } //如果可以三开印,也计算下三开的。 decimal totalprice3 = 0; bool Needchange = false; if (CutPaper.Kaidu % 3 == 0) { Model.PsSheet Sheet3 = new Model.PsSheet(3, CutPaper.Kaidu, PageNum); Model.PsSheet ps11 = Sheet3; while (ps11 != null) { Model.PartItem pips = MakePs(ps11); Model.PartItem piprint = MakePrint(ps11); Model.PartItem piopen = MakeOpen(ps11); totalprice3 += pips.Money; totalprice3 += piprint.Money; totalprice3 += piopen.Money; pips.Id += 30; piopen.Id += 30; piprint.Id += 30; AllItem.Add(pips); AllItem.Add(piprint); AllItem.Add(piopen); ps11 = ps11.Next; } if (totalprice3 < totalprice2) { Needchange = true; } else { List <Model.PartItem> Newlist = new List <Model.PartItem>(); foreach (Model.PartItem pi in AllItem) { if (!(pi.Id >= 30 && pi.Id < 40)) { if (pi.Id >= 20 && pi.Id < 30) { pi.Id = pi.Id - 20; } Newlist.Add(pi); } } AllItem = Newlist; Sheet = Sheet3; Ps.Kaidu = 2; Ps.Length = Paper.Length / 2; Ps.Width = Paper.Width; } } if (Needchange) { List <Model.PartItem> Newlist = new List <Model.PartItem>(); foreach (Model.PartItem pi in AllItem) { if (!(pi.Id >= 20 && pi.Id < 30)) { if (pi.Id >= 30 && pi.Id < 40) { pi.Id = pi.Id - 30; } Newlist.Add(pi); } } AllItem = Newlist; Sheet = Sheet2; Ps.Kaidu = 3; Ps.Length = Paper.Length / 3; Ps.Width = Paper.Width; } CalTotalNum(); AllExtendPaper += AllPsSet * 50; Part.PaperExtend = AllExtendPaper; CalAllNum(); return(result); #endregion }
private void button1_Click(object sender, EventArgs e) { try { int ptype = cbx_producter_type.SelectedIndex + 1;; PLen = int.Parse(text_Product_Len.Text); PWidth = int.Parse(text_Product_width.Text); num = int.Parse(text_producter_Num.Text); PageNum = int.Parse(text_Page_Num.Text); ColorNum = 0; if (checkBox2.Checked) { ColorNum = 0; } else { if (checkBox_c1.Checked) { ColorNum++; } if (checkBox_y1.Checked) { ColorNum++; } if (checkBox_k1.Checked) { ColorNum++; } if (checkBox_m1.Checked) { ColorNum++; } } op = new OrderPart(ptype, PLen, PWidth, num); op.PaperSource = checkBox_PaperSource.Checked; op.ColorNum = ColorNum; op.PageNum = PageNum; Model.NameType nt = (Model.NameType)comb_Paper.SelectedItem; op.PaperName = nt; if (op.MakePart()) { //检查页面数量的合法性;尤其是书本的开本和页数的关系;避免后面的计算出错 //checkPageNum() Model.Paper_Store paper = Model.Paper_Store.GetPaperById(nt.Id); Model.Rectange bp = new Model.Rectange(paper.Length, paper.Height); if (op.ProductType < 0) { MessageBox.Show("录入有错误,请重新检查输入项!"); return; } else { List <Model.NameType> needproces = Model.Process.GetProductProcess(ProductTypeId); if (needproces != null) { foreach (Model.NameType nt1 in needproces) { Model.PartItem pi = new Model.PartItem(); pi.PartType = 8; pi.PartName = "必选工艺"; pi.Name = nt1.Name; pi.Id = nt1.Id; pi.Num = num; pi.Price = 0; pi.Money = Model.C_ProcessPrice.GetProcessPrice(nt1.Id, num); op.AllItem.Add(pi); //op.AddProcess(nt1.Id); } } text_len.Text = op.Ps.Length.ToString(); text_width.Text = op.Ps.Width.ToString(); text_kaidu.Text = op.Ps.Kaidu.ToString(); text_needPaperNum1.Text = op.Part.PaperNum.ToString(); textBox_PsNum1.Text = op.AllPSnum.ToString(); textBox1.Text = op.AllPsSet.ToString(); text_lostnum.Text = op.Part.PaperExtend.ToString(); textBox2.Text = op.AllPrintNum.ToString(); BindView(); } } } catch { MessageBox.Show("录入有错误,请重新检查输入项!"); return; } }