Example #1
0
        private void delete_in_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(this, "确定删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                IList <String> in_id   = new List <String>();
                InKu_service   service = new InKu_service();
                int            count   = this.inku_datagridview.SelectedRows.Count;
                for (int i = 0; i < count; i++)
                {
                    if (this.inku_datagridview.SelectedRows[i].Cells[0].Value != null)
                    {
                        String id = this.inku_datagridview.SelectedRows[i].Cells[0].Value.ToString();
                        Console.WriteLine(id);

                        in_id.Add(id);
                    }
                }

                int result = service.deleteById(in_id);

                if (result != 0)
                {
                    MessageBox.Show("删除成功!");
                    initalData();
                }
                else
                {
                    MessageBox.Show("删除失败!");
                }
            }
        }
Example #2
0
        private void initalData()
        {
            Memange_service myservice  = new Memange_service();
            InKu_service    inservice  = new InKu_service();
            Outku_service   outservice = new Outku_service();
            IList <Remain>  remainlist = myservice.getAllRemainInfos();
            IList <InKu>    inkulist   = inservice.getAllInkus();
            IList <Outku>   outkulist  = outservice.getAllOutkus();

            this.dataGridView1.Rows.Clear();
            this.inku_datagridview.Rows.Clear();
            this.dataGridView2.Rows.Clear();

            for (int i = 0; i < remainlist.Count; i++)
            {
                Remain   remain = remainlist[i];
                String[] row    = { remain.Cangkuname, remain.Productname, remain.Remainnum.ToString() };
                this.dataGridView1.Rows.Add(row);
            }

            for (int j = 0; j < inkulist.Count; j++)
            {
                InKu     inku = inkulist[j];
                String[] row1 = { inku.In_id, inku.Pro_id, inku.In_time, inku.Cangku_id, inku.In_num.ToString() };
                this.inku_datagridview.Rows.Add(row1);
            }


            for (int k = 0; k < outkulist.Count; k++)
            {
                Outku    outku = outkulist[k];
                String[] row2  = { outku.Out_id, outku.Pro_id, outku.Out_time, outku.Cangku_id, outku.Out_num.ToString() };
                this.dataGridView2.Rows.Add(row2);
            }
        }
Example #3
0
        //显示所有
        private void button5_Click(object sender, EventArgs e)
        {
            InKu_service in_ser = new InKu_service();
            IList <InKu> list   = in_ser.getAllInkus();

            this.inku_datagridview.Rows.Clear();
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                InKu inku = list[i];

                String[] row = { inku.In_id, inku.Pro_id, inku.In_time, inku.Cangku_id, inku.In_num.ToString() };
                this.inku_datagridview.Rows.Add(row);
            }
        }
Example #4
0
        //查询
        private void search_in_Click(object sender, EventArgs e)
        {
            InKu_service in_ser   = new InKu_service();
            String       cangkuid = this.textBox3.Text;
            IList <InKu> list     = in_ser.getInkusByCangkuid(cangkuid);

            this.inku_datagridview.Rows.Clear();

            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                InKu inku = list[i];

                String[] row = { inku.In_id, inku.Pro_id, inku.In_time, inku.Cangku_id, inku.In_num.ToString() };
                this.inku_datagridview.Rows.Add(row);
            }
        }
Example #5
0
        //添加入库
        private void add_in_Click(object sender, EventArgs e)
        {
            Product_service pro_ser = new Product_service();
            Memange_service me_ser  = new Memange_service();
            InKu_service    in_ser  = new InKu_service();

            IList <InKu> WhatToInKus = new List <InKu>();

            //添加之前先检查库存是否有这种产品,要是没有,就添加,同时插入产品表,以及库存表,要是没有,添加,然后修改库存表
            for (int i = 0; i < WhatToInKu.Count / 3; i++)
            {
                InKu inku = new InKu();
                // inku.In_id = WhatToInKu[3 * i + 0];
                //获取产品ID
                String id = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);
                if (id.Length == 0)
                {
                    //插入产品及库存

                    pro_ser.addProduct(WhatToInKu[3 * i + 0]);

                    Remain remain = new Remain();
                    remain.Cangkuname  = WhatToInKu[3 * i + 1];
                    remain.Remainnum   = Convert.ToInt32(WhatToInKu[3 * i + 2]);
                    remain.Productname = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);
                    int k = me_ser.addRemain(remain);//插入库存表

                    Console.WriteLine(k + "[][][][][][][]");
                }
                else
                {
                    //修改库存表

                    Remain remain = new Remain();
                    remain.Cangkuname  = WhatToInKu[3 * i + 1];
                    remain.Remainnum   = Convert.ToInt32(WhatToInKu[3 * i + 2]) + me_ser.getRemainNum(pro_ser.getIdByName(WhatToInKu[3 * i + 0]));
                    remain.Productname = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);
                    me_ser.updateRemain(remain);
                }
                inku.Pro_id    = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);
                inku.In_time   = DateTime.Now.Date.ToShortDateString();
                inku.Cangku_id = WhatToInKu[3 * i + 1];
                inku.In_num    = Convert.ToInt32(WhatToInKu[3 * i + 2]);
                WhatToInKus.Add(inku);
            }

            int result = in_ser.addKu(WhatToInKus);

            if (result != 0)
            {
                MessageBox.Show("添加成功!");
                initalData();
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
            int count = WhatToInKu.Count;

            for (int i = count - 1; i >= 0; i--)
            {
                WhatToInKu.RemoveAt(i);
            }
        }