Esempio n. 1
0
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <Model.Paper_Out> wp = (List <Model.Paper_Out>)comboBox3.DataSource;

            Model.Paper_Out po = wp[comboBox3.SelectedIndex];
            textBox1.Text = po.Num.ToString();
        }
Esempio n. 2
0
        private void button9_Click(object sender, EventArgs e)
        {
            DateTime LastTime             = dateTimePicker1.Value;
            List <Model.Paper_Out> AllOut = Model.Paper_Out.GetYearMonthList(LastTime);

            if (AllOut != null && AllOut.Count > 0)
            {
                int     AllNum   = 0;
                decimal AllMoney = 0;

                List <Model.Paper_Out> Reslut = new List <Model.Paper_Out>();
                for (int i = 0; i < AllOut.Count; i++)
                {
                    if (AllOut[i].Remark.IndexOf("业务部") + AllOut[i].Remark.IndexOf("手动单笔") < -1 || AllOut[i].PaperId == 0)
                    {
                        continue;
                    }
                    int PaperId = AllOut[i].PaperId;
                    Reslut.Add(AllOut[i]);
                    AllNum           += AllOut[i].Num;
                    AllMoney         += AllOut[i].Money;
                    AllOut[i].PaperId = 0;
                    for (int j = i; j < AllOut.Count - i; j++)
                    {
                        if (PaperId == AllOut[j].PaperId)
                        {
                            if (AllOut[j].Remark.IndexOf("业务部") + AllOut[j].Remark.IndexOf("手动单笔") < -1)
                            {
                                continue;
                            }
                            Reslut.Add(AllOut[j]);
                            AllOut[j].PaperId = 0;
                            AllNum           += AllOut[j].Num;
                            AllMoney         += AllOut[j].Money;
                        }
                    }
                }
                if (Reslut.Count > 0)
                {
                    Model.Paper_Out TotalOut = new Model.Paper_Out();
                    TotalOut.PaperName = "合计";
                    TotalOut.Num       = AllNum;
                    TotalOut.Money     = AllMoney;
                    Reslut.Add(TotalOut);
                    CurrentData = DataSource.ORMHelper.ModelListToTb <Model.Paper_Out>(Reslut);
                    dataGridView1.DataSource = CurrentData;
                    List <string> title = Model.Paper_Out.GetColumNikeName();
                    for (int i = 0; i < title.Count; i++)
                    {
                        dataGridView1.Columns[i].HeaderText = title[i];
                    }
                    CurrentData.TableName = "业务部出库汇总表";
                }
            }
            else
            {
                MessageBox.Show(LastTime.ToShortDateString() + "还没有出库记录!");
            }
        }
Esempio n. 3
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (comboBox2.SelectedItem == null)
            {
                MessageBox.Show("请先选择目标纸张!");
                return;
            }
            if (comboBox3.SelectedItem == null)
            {
                MessageBox.Show("请先选择要修改的纸张!");
                return;
            }

            int num = 0;

            if (!int.TryParse(textBox1.Text, out num))
            {
                MessageBox.Show("请先输入要修改的纸张的数量!");
                return;
            }
            Model.NameType  SelectedPaper = (Model.NameType)comboBox2.SelectedItem;
            Model.Paper_Out OutPaper      = (Model.Paper_Out)comboBox3.SelectedItem;

            Model.Paper_Store NewPaper = Model.Paper_Store.GetPaperById(SelectedPaper.Id);

            if (MaterialList != null)
            {
                Model.P_MaterialList2 pm2 = MaterialList[comboBox2.SelectedIndex];
                pm2.StandName = SelectedPaper.Name;
                pm2.StandId   = SelectedPaper.Id;
                pm2.UnitPrice = NewPaper.UnitPrice;
                pm2.Price     = (int)Math.Round(OutPaper.Money, 0);
                pm2.Num       = OutPaper.Num;
                if (DataSource.ORMHelper.UpdateModelById <Model.P_MaterialList2>(pm2) == 0)
                {
                    DialogResult dr = MessageBox.Show("订单信息修改失败,确认是否继续修改出入库记录!", "确认", MessageBoxButtons.YesNo);
                    if (dr != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }
            //读出新的纸张和老的纸张;
            //如果已经出库,还要修改出库记录,及库存记录;
            if (!NoOut)
            {
                Model.Paper_Store OldPaper = Model.Paper_Store.GetPaperById(OutPaper.PaperId);
                //修改相关记录;
                OldPaper.Num       += OutPaper.Num;
                OldPaper.Money     += OutPaper.Money;
                NewPaper.Num       -= num;
                OutPaper.Num        = num;
                OutPaper.Money      = NewPaper.TaxiPrice * num;
                NewPaper.TaxiMoney -= OutPaper.Money;
                OutPaper.PaperId    = NewPaper.PaperId;
                OutPaper.PaperName  = NewPaper.PaperName;
                OutPaper.Price      = NewPaper.TaxiPrice;

                if (Model.Paper_Out.Update(OutPaper) < 1)
                {
                    MessageBox.Show("修改出库记录失败,确认后退出!");
                    return;
                }
                if (Model.Paper_Store.Update(OldPaper) + Model.Paper_Store.Update(NewPaper) == 2)
                {
                    MessageBox.Show("修改出库记录及库存数据成功,确认后退出!");
                }
            }
        }
Esempio n. 4
0
        private void button7_Click(object sender, EventArgs e)
        {
            string OrderNo = text_oldpaper.Text.Trim();
            string OrderOn = "";

            NoOut = false;
            DataTable WaitOutPaper = null;

            Model.P_Order order   = Model.P_Order.GetOrderByOrder(OrderNo);
            DataTable     tempout = null;

            if (order != null)
            {
                string pubno1 = order.OrderOn.Replace("O", "PUB");
                OrderOn      = pubno1;
                MaterialList = Model.P_MaterialList2.GetDataList("OrderOn='" + pubno1 + "' and Mtype='1'");
                if (MaterialList != null && MaterialList.Count > 0)
                {
                    List <Model.Paper_Out> OutList = new List <Model.Paper_Out>();
                    foreach (Model.P_MaterialList2 pm2 in MaterialList)
                    {
                        Model.Paper_Out po11 = new Model.Paper_Out();
                        po11.PaperName = pm2.b2;
                        po11.PaperId   = pm2.b1;
                        po11.Num       = pm2.Num;
                        OutList.Add(po11);
                    }
                    tempout = DataSource.ORMHelper.ModelListToTb <Model.Paper_Out>(OutList);
                }
                else
                {
                    MessageBox.Show("订单号错误或该订单没有纸张,请重新输入!");
                    return;
                }
            }

            //检查是否有出库;
            WaitOutPaper = Model.Paper_Out.GetDataTable(" b1='" + OrderNo + "'");
            if (WaitOutPaper != null && WaitOutPaper.Rows.Count > 0)
            {
                NoOut = false;
            }
            else
            {
                WaitOutPaper = tempout;
            }

            dataGridView1.DataSource = WaitOutPaper;
            List <string> title = Model.Paper_Out.GetColumNikeName();

            for (int i = 0; i < title.Count; i++)
            {
                dataGridView1.Columns[i].HeaderText = title[i];
            }
            dataGridView1.AutoSize = true;

            this.Cursor = Cursors.Default;
            List <Model.Paper_Out> wp = Model.Paper_Out.PaperoutTabletoList(WaitOutPaper);

            comboBox3.DataSource    = wp;
            comboBox3.DisplayMember = "PaperName";
            comboBox3.SelectedIndex = 0;
            Model.Paper_Out po = wp[0];
            textBox1.Text = po.Num.ToString();
        }
Esempio n. 5
0
        private void button4_Click(object sender, EventArgs e)
        {
            int type = 0;

            type = int.Parse(comboBox1.SelectedValue.ToString());
            Model.Paper_Store paper = Model.Paper_Store.GetPaperById(type);

            if (!(comboBox1.Items.Count > 0 && comboBox1.SelectedIndex >= 0))
            {
                MessageBox.Show("通过拼音简写选择要出库的纸张!", "提示");
                return;
            }

            if (Out == null)
            {
                Out = new List <Model.Paper_Out>();
            }

            int  num     = 0;
            bool inputok = true;

            inputok = inputok && int.TryParse(txt_num.Text, out num);
            if (!inputok)
            {
                MessageBox.Show("检查纸数量!");
                return;
            }
            if (paper.Num < num)
            {
                DialogResult dr = MessageBox.Show("即将出库的数量大于库存内数量,确认需要出库!", "提示", MessageBoxButtons.YesNo);
                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }
            Model.Paper_Out pi = new Model.Paper_Out()
            {
                Id        = 0,
                Num       = num,
                PaperId   = paper.PaperId,
                PaperName = paper.PaperName,
                Price     = paper.TaxiPrice,
                Money     = paper.TaxiPrice * num,
                OutTime   = dateTimePicker1.Value,
                RealTime  = DateTime.Now,
                Remark    = "手动单笔出库",
                b1        = "系统"
            };
            Out.Add(pi);
            if (SaveTable == null)
            {
                DataTable InData = DataSource.ORMHelper.ModelListToTb <Model.Paper_Out>(Out);
                SaveTable = InData;
            }
            else
            {
                DataRow dr = DataSource.ORMHelper.ModelToRow <Model.Paper_Out>(pi);
                SaveTable.ImportRow(dr);
            }
            dataGridView1.DataSource = SaveTable;
            SetInTitle();
            txt_num.Text = "";
        }
Esempio n. 6
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            DataTable inputdata = (DataTable)dataGridView1.DataSource;

            if (inputdata != null)
            {
                int NameColIndex = -1;
                int NumColIndex  = -1;
                int DateColIndex = -1;

                int.TryParse(name_col.Text, out NameColIndex);
                int.TryParse(num_col.Text, out NumColIndex);
                int.TryParse(datecol.Text, out DateColIndex);
                try
                {
                    if (isincol(NameColIndex) && isincol(NumColIndex) && isincol(DateColIndex))
                    {
                        if (inputdata.Columns.Count > 0)
                        {
                            NameColIndex = NameColIndex - 1;
                            NumColIndex  = NumColIndex - 1;
                            DateColIndex = DateColIndex - 1;

                            List <Model.Paper_Out> AllOut = new List <Model.Paper_Out>();

                            List <Model.Paper_Store> AllPaperList = Model.Paper_Store.GetAllPaperList();

                            List <Model.Paper_Store> NeedUpdateList = new List <Model.Paper_Store>();

                            foreach (DataRow dr in inputdata.Rows)
                            {
                                string          papername = dr[NameColIndex].ToString();
                                Model.Paper_Out pi        = new Model.Paper_Out();
                                pi.PaperName = papername;
                                pi.PaperId   = -1;

                                foreach (Model.Paper_Store paper  in AllPaperList)
                                {
                                    if (paper.PaperName == pi.PaperName)
                                    {
                                        pi.PaperId = paper.PaperId;
                                        pi.Num     = int.Parse(dr[NumColIndex].ToString());
                                        if (pi.Num == 0)
                                        {
                                            continue;
                                        }
                                        pi.Price      = paper.TaxiPrice;
                                        pi.Money      = Math.Round(pi.Num * pi.Price, 2);
                                        pi.RealTime   = DateTime.Now;
                                        pi.OutTime    = DateTime.Parse(dr[DateColIndex].ToString());
                                        pi.SourceCode = "批量出库";
                                        AllOut.Add(pi);
                                        break;
                                    }
                                }
                            }
                            if (AllOut.Count > 0)
                            {
                                DataTable PaperOut = DataSource.ORMHelper.ModelListToTb <Model.Paper_Out>(AllOut);
                                if (PaperOut != null)
                                {
                                    dataGridView1.DataSource = PaperOut;
                                    List <string> title = Model.Paper_Out.GetColumNikeName();
                                    for (int i = 0; i < title.Count; i++)
                                    {
                                        dataGridView1.Columns[i].HeaderText = title[i];
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("请检查输入文件的格式,或重新输入队列对应关系!");
                }
            }
        }