示例#1
0
文件: TreeNode.cs 项目: xiaofengtan/-
        public decimal GetPaperRation(int l, int h, List <Model.PaperTreeNode> list)
        {
            Model.Rectange rect1 = new Model.Rectange(l, h);
            rect1.Kaidu = list[0].Kaidu;
            decimal r = rect1.GetRatio(list[list.Count - 1].Node2Rect());

            r = decimal.Round(r * 100, 2);
            return(r);
        }
示例#2
0
 public OrderPart(int id, int len, int width, int num)
 {
     Product     = new Model.Rectange(len, width);
     ProductNum  = num;
     ProductType = id;
     AllItem     = new List <Model.PartItem>();
     Part        = new Model.OrderPart();
     Part.Num    = num;
 }
示例#3
0
 private void text_producter_Num_Leave(object sender, EventArgs e)
 {
     PLen   = int.Parse(text_Product_Len.Text);
     PWidth = int.Parse(text_Product_width.Text);
     num    = int.Parse(text_producter_Num.Text);
     if (PLen > 0 && Width > 0 && num > 0)
     {
         // Model.Rectange ProductRect = new Model.Rectange(PLen, PWidth);
         Model.Tree CutTree = Model.Common.PaperCut;
         BigPaperSize = CutTree.GetPaper(PLen, PWidth);
         if (BigPaperSize == Model.Common.BigPaper)
         {
             text_papercode.Text = "dg";
         }
         if (BigPaperSize == Model.Common.SmallPaper)
         {
             text_papercode.Text = "zg";
         }
     }
     else
     {
         MessageBox.Show("录入错误");
     }
 }
示例#4
0
        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
        }
示例#5
0
        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;
            }
        }