Beispiel #1
0
        public Paper(int id, int sizeid)
        {
            Model.Paper_Stand p = DAL.Paper_Stand.GetModel(id);
            if (p != null)
            {
                if (sizeid < 2)
                {
                    p.StandName = "正规" + p.StandName;
                }
                else
                {
                    p = DAL.Paper_Stand.GetModel("StandName like '%" + p.StandName + "%' and SizeId=1");
                    if (p == null)
                    {
                        p = DAL.Paper_Stand.GetModel(id);
                    }
                    p.StandName = "大规" + p.StandName;
                }
                Id         = p.Id;
                kg         = p.KG;
                PaperName  = p.StandName;
                PaperPrice = p.SalesUnitPrice;

                int t = p.TypeId;
                int xishu;
                switch (t)
                {
                case 1:
                {
                    xishu = ConstantValue.Paper.ThickTB;
                    break;
                }

                case 2:
                {
                    xishu = ConstantValue.Paper.ThickSJ;
                    break;
                }

                case 6:
                {
                    xishu = ConstantValue.Paper.ThickYF;
                    break;
                }

                default:
                {
                    xishu = ConstantValue.Paper.ThickOther;
                    break;
                }
                }
                ThickXishu = xishu;
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Model.Paper_Store ps = new Model.Paper_Store();
            ps.TypeId = cbx_type.SelectedIndex;
            string  PaperName = "";
            string  StandName = "";
            decimal unitprice = 0;
            int     tonprice  = 0;

            //ps.StandId = 98;

            ps.PaperFactory = text_factor.Text.Trim();
            if (ps.PaperFactory.Length < 1)
            {
                MessageBox.Show("纸张品牌输入有误,检查输入!");
                return;
            }

            if (comboBox1.SelectedIndex == 2)
            {
                PaperName = "非标";
                int  len = 0, width = 0;
                bool input = int.TryParse(text_len.Text, out len);
                input = input && int.TryParse(text_width.Text, out width);
                if (!input)
                {
                    MessageBox.Show("自定义尺寸输入有误,检查输入!");
                    return;
                }
                else
                {
                    ps.Length = len;
                    ps.Height = width;
                }
            }
            if (comboBox1.SelectedIndex == 0)
            {
                PaperName = "大规";
                ps.Length = 880;
                ps.Height = 1194;
            }
            if (comboBox1.SelectedIndex == 1)
            {
                PaperName = "正规";
                ps.Length = 780;
                ps.Height = 1092;
            }

            int kg = 0;

            if (!int.TryParse(text_kg.Text, out kg))
            {
                MessageBox.Show("纸张克重输入有误,检查输入!");
                return;
            }
            ps.Kg      = kg;
            PaperName += kg.ToString() + "g";

            decimal price = 0;

            if (!decimal.TryParse(text_unitprice.Text, out price))
            {
                MessageBox.Show("纸张销售价输入有误,检查输入!");
                return;
            }
            //ps.UnitPrice = unitprice;

            StandName  = PaperName;
            PaperName += text_factor.Text;
            string typename = cbx_type.Text;

            PaperName += typename;
            StandName += typename;

            ps.PaperName = PaperName;
            ps.StandId   = 0;
            foreach (DataRow dr in allpaper.Rows)
            {
                if (ps.PaperName == dr["PaperName"].ToString())
                {
                    ps.StandId = int.Parse(dr["StandId"].ToString());
                    break;
                }
            }
            if (ps.StandId > 0)
            {
                MessageBox.Show("该纸张已经存在,请确认和检查输入!");
                return;
            }

            foreach (Model.Paper_Stand psd in Allstand)
            {
                if (psd.StandName == StandName)
                {
                    ps.StandId = psd.Id;
                }
            }
            if (ps.StandId == 0)
            {
                if (checkBox1.Checked)
                {
                    unitprice = price;
                    tonprice  = decimal.ToInt32(Common.CalNumPreTon(ps.Length, ps.Height, ps.Kg) * unitprice);
                }
                else
                {
                    tonprice  = decimal.ToInt32(price);
                    unitprice = Math.Round(price / Common.CalNumPreTon(ps.Length, ps.Height, ps.Kg), 2);
                }

                Model.Paper_Stand psd = new Model.Paper_Stand {
                    StandName = StandName, KG = kg, SizeId = comboBox1.SelectedIndex + 1, TypeId = int.Parse(cbx_type.SelectedValue.ToString())
                };
                psd.SalesUnitPrice = unitprice;
                psd.SalesTonPrice  = tonprice;

                DataSource.ORMHelper.InsertModel <Model.Paper_Stand>(psd);
                Allstand = Model.Paper_Stand.GetDataList("1=1");
                foreach (Model.Paper_Stand psd1 in Allstand)
                {
                    if (psd1.StandName == StandName)
                    {
                        ps.StandId = psd1.Id;
                        break;
                    }
                }
            }
            if (ps.StandId > 0)
            {
                ps.TonPrice = tonprice;
                ps.TypeId   = cbx_type.SelectedIndex;
                if (ps.PaperName != null)
                {
                    ps.PaperCode = Model.Common.GetChineseSpell(ps.PaperName);
                }
                if (Model.Paper_Store.InserData(ps) > 0)
                {
                    MessageBox.Show(ps.PaperName + " 纸张已经添加!");
                }
                else
                {
                    MessageBox.Show(ps.PaperName + " 纸张添加失败!");
                    return;
                }

                for (int i = 0; i < AllProduct.Count; i++)
                {
                    if (checkedListBox1.GetSelected(i))
                    {
                        int id = AllProduct[i].ProductId;
                        Model.R_ProductPaper rpp = new Model.R_ProductPaper()
                        {
                            ProductId = id, StandId = ps.StandId
                        };
                        Model.R_ProductPaper.InserData(rpp);
                    }
                }
            }

            //BindData();
        }