Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int            count   = this.dataGridView1.Rows.Count;
            IList <Remain> remains = new List <Remain>();

            for (int i = 0; i < count - 1; i++)
            {
                Remain remain = new Remain();
                Console.WriteLine(i);
                remain.Cangkuname  = this.dataGridView1.Rows[i].Cells[0].Value.ToString();
                remain.Productname = this.dataGridView1.Rows[i].Cells[1].Value.ToString();
                remain.Remainnum   = Convert.ToInt32(this.dataGridView1.Rows[i].Cells[2].Value.ToString());

                remains.Add(remain);
            }

            Memange_service myservice = new Memange_service();

            int result = myservice.addRemain(remains);

            this.Close();
            if (result != 0)
            {
                MessageBox.Show("添加成功!");
            }
            else
            {
                MessageBox.Show("添加失败,请检查原因!");
            }
        }
Esempio n. 3
0
        public IList <Remain> getAllRemainInfos()
        {
            IList <Remain> list = new List <Remain>();
            String         sql  = "select * from remain_state";

            MySqlDataReader reader = helper.GetReader(sql);

            while (reader.Read())
            {
                Remain remain = new Remain();

                remain.Remainnum = (int)reader["remain"];

                int cangkuid = (int)reader["cangku_id"];

                int productid = (int)reader["product_id"];

                MySqlDataReader reader1 = helper.GetReader("select storehouse_name from storehouse where storehouse_id = '" + cangkuid + "'");

                if (reader1.Read())
                {
                    remain.Cangkuname = reader1["storehouse_name"].ToString();
                }

                MySqlDataReader reader2 = helper.GetReader("select product_name from product where product_id = '" + productid + "'");

                if (reader2.Read())
                {
                    remain.Productname = reader2["product_name"].ToString();
                }
                list.Add(remain);
            }

            return(list);
        }
Esempio n. 4
0
        public void CalculateTest(double firstValue, double secondValue, double expected)
        {
            var calculator   = new Remain();
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
Esempio n. 5
0
        public int addRemain(Remain remain)
        {
            int    result = 0;
            String sql    = "insert into remain_state(cangku_id,product_id,remain) values('" + remain.Cangkuname + "','" + remain.Productname + "','" + remain.Remainnum + "')";

            result = helper.ExecuteCommand(sql);
            return(result);
        }
Esempio n. 6
0
        public void WhenX13Y4_ShouldResult3(
            [Values(13)] double x,
            [Values(4)] double y
            )
        {
            var operation = new Remain(x, y);

            Assert.AreEqual(1, operation.Operate());
        }
Esempio n. 7
0
        public int updateRemain(Remain remain)
        {
            String pro_id = remain.Productname;
            String sql    = "update remain_state set remain='" + remain.Remainnum + "' where product_id='" + pro_id + "'";

            int result = helper.ExecuteCommand(sql);

            return(result);
        }
Esempio n. 8
0
        public void WhenX1Y0_ShouldThrowDivideByZero(
            [Values(1)] double x,
            [Values(0)] double y
            )
        {
            var operation = new Remain(x, y);

            Assert.Throws <DivideByZeroException>(() => { var result = operation.Operate(); });
        }
        private void CalQty()
        {
            try
            {
                if (RadioButtonList1.SelectedValue == "รับสินค้าทั้งหมด")
                {
                    txtNewDelQty.Text = (Convert.ToInt32(lblQty.Text) - Convert.ToInt32(lblRecieveQty.Text)).ToString();
                    int TotalQtr = Convert.ToInt32(lblQty.Text);
                    int DelQty   = Convert.ToInt32(lblRecieveQty.Text);
                    int NewDel   = Convert.ToInt32(txtNewDelQty.Text);
                    int Remain;

                    Remain = (TotalQtr - DelQty) - NewDel;
                    lblRemainedRecieve.Text = Remain.ToString();
                }
                else if (RadioButtonList1.SelectedValue == "รับสินค้าบางส่วน")
                {
                    if (Convert.ToInt32(txtNewDelQty.Text) >= ((Convert.ToInt32(lblQty.Text) - Convert.ToInt32(lblRecieveQty.Text))))
                    {
                        MessageBox.Show("จำนวนสินค้าควรมีค่าน้อยกว่า " + ((Convert.ToInt32(lblQty.Text) - Convert.ToInt32(lblRecieveQty.Text)) + "  ชิ้น"));
                    }
                    else
                    {
                        int TotalQtr = Convert.ToInt32(lblQty.Text);
                        int DelQty   = Convert.ToInt32(lblRecieveQty.Text);
                        int NewDel   = Convert.ToInt32(txtNewDelQty.Text);
                        int Remain;

                        Remain = (TotalQtr - DelQty) - NewDel;
                        lblRemainedRecieve.Text = Remain.ToString();
                    }
                }

                else
                {
                    if (Convert.ToInt32(txtNewDelQty.Text) < ((Convert.ToInt32(lblQty.Text) - Convert.ToInt32(lblRecieveQty.Text))))
                    {
                        MessageBox.Show("จำนวนสินค้าควรมีค่ามากกว่า " + ((Convert.ToInt32(lblQty.Text) - Convert.ToInt32(lblRecieveQty.Text)) + "  ชิ้น"));
                    }
                    else
                    {
                        int TotalQtr = Convert.ToInt32(lblQty.Text);
                        int DelQty   = Convert.ToInt32(lblRecieveQty.Text);
                        int NewDel   = Convert.ToInt32(txtNewDelQty.Text);
                        int Remain;

                        Remain = (TotalQtr - DelQty) - NewDel;
                        lblRemainedRecieve.Text = Remain.ToString();
                    }
                }
            }
            catch
            {
                MessageBox.Show("กรุณากรอกจำนวนการรับสินค้าให้ถูกต้อง");
            }
        }
Esempio n. 10
0
        private void dataGridView1_CellValueChanged(
            object sender, DataGridViewCellEventArgs e)
        {
            Console.WriteLine(e.RowIndex + "--------" + e.ColumnIndex);
            Remain remain = new Remain();

            if (e.RowIndex >= 0)
            {
                remain.Cangkuname  = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                remain.Productname = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                remain.Remainnum   = Convert.ToInt32(this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                WitchToUpdate.Add(remain);
            }
        }
        private void CalQty()
        {
            try
            {
                double TotalQtr = Convert.ToDouble(lblQty.Text);
                double DelQty   = Convert.ToDouble(lblDelQty.Text);
                double NewDel   = Convert.ToDouble(txtNewDelQty.Text);
                double Remain;

                Remain            = (TotalQtr - DelQty) - NewDel;
                lblRemainDel.Text = Remain.ToString();
            }
            catch
            {
                MessageBox.Show("กรุณากรอกจำนวนการส่งสินค้าให้ถูกต้อง");
            }
        }
Esempio n. 12
0
        private void button2_Click(object sender, EventArgs e)
        {
            Memange_service menageservice = new Memange_service();

            IList <Remain> list = menageservice.getAllRemainInfos();

            this.dataGridView1.Rows.Clear();



            for (int i = 0; i < list.Count; i++)
            {
                Remain remain = list[i];

                String[] row = { remain.Cangkuname, remain.Productname, remain.Remainnum.ToString() };

                this.dataGridView1.Rows.Add(row);
            }
        }
Esempio n. 13
0
        //查询。。。
        private void button1_Click(object sender, EventArgs e)
        {
            String          cangku_id  = this.cangku_id_text.Text;
            String          product_id = this.pro_id_text.Text;
            IList <Remain>  remains    = null;
            Memange_service service    = new Memange_service();

            if (product_id.Length != 0 && cangku_id.Length != 0)//11
            {
                String sql = "select * from remain_state where cangku_id='" + cangku_id + "' and product_id='" + product_id + "'";
                remains = service.getRemains(sql);
            }
            else if (product_id.Length != 0 && cangku_id.Length == 0)//10
            {
                String sql = "select * from remain_state where  product_id='" + product_id + "'";
                remains = service.getRemains(sql);
            }
            else if (product_id.Length == 0 && cangku_id.Length != 0)//01
            {
                String sql = "select * from remain_state where cangku_id='" + cangku_id + "'";
                remains = service.getRemains(sql);
            }
            else//00
            {
                MessageBox.Show("请选择查询方式!");
            }


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

                    this.dataGridView1.Rows.Add(row);
                }
            }
        }
Esempio n. 14
0
        //修改。。。。
        private void update_kucun_Click(object sender, EventArgs e)
        {
            Memange_service service   = new Memange_service();
            int             count     = WitchToUpdate.Count;
            IList <String>  errorList = new List <String>();

            for (int i = 0; i < count; i++)
            {
                String id     = service.getProIdByName(WitchToUpdate[0].Productname);
                Remain remain = new Remain();

                remain.Productname = id;
                remain.Remainnum   = WitchToUpdate[0].Remainnum;
                remain.Cangkuname  = WitchToUpdate[0].Cangkuname;
                int result = service.updateRemain(remain);
                WitchToUpdate.RemoveAt(0);

                if (result == 0)
                {
                    errorList.Add(WitchToUpdate[i].Productname);
                }
            }


            if (errorList.Count != 0)
            {
                String note = "";
                for (int j = 0; j < errorList.Count; j++)
                {
                    note += errorList[j] + "修改失败!\n";
                }
                MessageBox.Show(note);
            }
            else
            {
                MessageBox.Show("修改成功!");
                initalData();
            }
        }
Esempio n. 15
0
        private void button9_Click(object sender, EventArgs e)
        {
            Product_service pro_ser = new Product_service();
            Memange_service me_ser  = new Memange_service();
            Outku_service   out_ser = new Outku_service();

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

            // 出库之前先检查库存是否有这种产品,要是没有,出库失败,要是有,添加出库单,然后修改库存表
            for (int i = 0; i < WhatToInKu.Count / 3; i++)
            {
                Outku outku = new Outku();
                // inku.In_id = WhatToInKu[3 * i + 0];
                //获取产品ID
                String id = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);

                if (id.Length == 0)
                {
                    //插入产品及库存

                    MessageBox.Show("仓库中不存在" + WhatToInKu[3 * i + 0]);
                    return;
                }
                else
                {
                    //修改库存表

                    Remain remain = new Remain();
                    remain.Cangkuname = WhatToInKu[3 * i + 1];
                    Console.WriteLine(me_ser.getRemainNum(pro_ser.getIdByName(WhatToInKu[3 * i + 0])));
                    Console.WriteLine(Convert.ToInt32(WhatToInKu[3 * i + 2]));

                    remain.Remainnum = me_ser.getRemainNum(pro_ser.getIdByName(WhatToInKu[3 * i + 0])) - Convert.ToInt32(WhatToInKu[3 * i + 2]);
                    Console.WriteLine(remain.Remainnum);
                    remain.Productname = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);
                    me_ser.updateRemain(remain);
                }
                outku.Pro_id    = pro_ser.getIdByName(WhatToInKu[3 * i + 0]);
                outku.Out_time  = DateTime.Now.Date.ToShortDateString();
                outku.Cangku_id = WhatToInKu[3 * i + 1];
                outku.Out_num   = Convert.ToInt32(WhatToInKu[3 * i + 2]);
                WhatToInKus.Add(outku);
            }

            int result = out_ser.outKu(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);
            }
        }
Esempio n. 16
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);
            }
        }
Esempio n. 17
0
        protected void GridView3_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblJobItemID.Text = GridView2.SelectedRow.Cells[0].Text;
            lblRawID.Text     = GridView3.SelectedRow.Cells[1].Text;
            lblRawName.Text   = GridView3.SelectedRow.Cells[2].Text;
            lblTotalQty.Text  = GridView3.SelectedRow.Cells[5].Text;
            lblUnit1.Text     = GridView3.SelectedRow.Cells[6].Text;
            lblUnit2.Text     = GridView3.SelectedRow.Cells[6].Text;
            lblUnit3.Text     = GridView3.SelectedRow.Cells[6].Text;
            lblUnit4.Text     = GridView3.SelectedRow.Cells[6].Text;
            lblUnit5.Text     = GridView3.SelectedRow.Cells[6].Text;
            lblUnit6.Text     = GridView3.SelectedRow.Cells[6].Text;

            txtWithdrawQty.Text = "0.00";
            lblDate.Text        = DateTime.Now.Date.ToString("dd/MM/yyyy");

            string    findWithdrawQty = "Select SUM(MatWithdrawQty) AS SumWithdrawMat FROM MaterialWithdrawals WHERE JobItemID = '" + GridView2.SelectedRow.Cells[0].Text + "' AND JobItemMatID = '" + GridView3.SelectedRow.Cells[0].Text + "';";
            DataTable dt = dbconn.QueryExecuteScalar(findWithdrawQty);

            try
            {
                if (Convert.ToDouble(GridView3.SelectedRow.Cells[5].Text) > Convert.ToDouble(dt.Rows[0]["SumWithdrawMat"]))
                {
                    txtWithdrawQty.Text    = "0.00";
                    txtWithdrawQty.Enabled = false;
                    lblWithdrawQty.Text    = dt.Rows[0]["SumWithdrawMat"].ToString();
                }
                else if (Convert.ToDouble(GridView3.SelectedRow.Cells[5].Text) == Convert.ToDouble(dt.Rows[0]["SumWithdrawMat"]))
                {
                    txtWithdrawQty.Enabled = false;
                    lblWithdrawQty.Text    = Convert.ToDouble(dt.Rows[0]["SumWithdrawMat"]).ToString();
                }
                else
                {
                    txtWithdrawQty.Enabled = true;
                    lblWithdrawQty.Text    = Convert.ToDouble(dt.Rows[0]["SumWithdrawMat"]).ToString();
                }
            }

            catch
            {
                lblWithdrawQty.Text = "0.00";
            }


            double RequireQty  = Convert.ToDouble(lblTotalQty.Text);
            double WithdrawQty = Convert.ToDouble(lblWithdrawQty.Text);
            double Remain;

            Remain            = RequireQty - WithdrawQty;
            lblRemainQty.Text = Remain.ToString("#,###.00");

            if (Remain >= 0)
            {
                RadioButtonList1.SelectedValue = "ยังเบิกสินค้ายังไม่ครบ";
            }
            else
            {
                RadioButtonList1.SelectedValue = "เบิกสินค้าครบแล้ว";
            }

            if (RadioButtonList1.SelectedValue == "เบิกสินค้าครบแล้ว")
            {
                txtWithdrawQty.Text    = "0.00";
                txtWithdrawQty.Enabled = false;
            }
            else
            {
                txtWithdrawQty.Enabled = true;
            }

            string Stock = "SELECT * FROM RawMaterials WHERE RawID = '" + GridView3.SelectedRow.Cells[0].Text + "';";

            DataTable dtStock = dbconn.QueryExecuteScalar(Stock);

            try
            {
                string stockQty = dtStock.Rows[0]["RawQty"].ToString();
                lblStock.Text = stockQty;
            }
            catch
            {
                lblStock.Text = "0.00";
            }
        }