예제 #1
0
        private void checkType(String type)
        {
            String ID = dataGridView2.CurrentRow.Cells["ProductID"].Value.ToString();
            String qtyp = dataGridView2.CurrentRow.Cells["QuantityPack"].Value.ToString();
            String qty = dataGridView2.CurrentRow.Cells["Quantity"].Value.ToString();
            String tw = dataGridView2.CurrentRow.Cells["Detail"].Value.ToString();
            //DataTable dt = Class.Function.GetContentAsDataTable(dataGridView1);
            //DataRow[] r = dt.Select("mid = " + dataGridView2.CurrentRow.Cells["Mid"].Value.ToString());
            String q = "0";
            //String d = "";
            //for (int i = 0; i < r.Length; i++)
            //{
            //    q = r[i][2].ToString();
            //    d = r[i][0].ToString();
            //}
            Double sum = 0;
            //foreach( DataGridViewRow row in dataGridView2.Rows ){
            //    if (d == row.Cells["Mid"].Value.ToString() && row.Cells["ProductID"].Value.ToString() != ID)
            //    {
            //        sum += (row.Cells["Quantity"].Value.ToString() == "") ? 0 : Convert.ToDouble(row.Cells["Quantity"].Value);
            //    }
            //}
            ProductionNew.frmAddReturn FrmAddReq = new ProductionNew.frmAddReturn(type, ID, tw, qtyp, qty, q, sum,1);
            FrmAddReq.ShowDialog();
            if (FrmAddReq.DialogResult == DialogResult.Yes)
            {
                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    if (row.Cells["ProductID"].Value.ToString() == ID)
                    {
                        row.Cells["QuantityPack"].Value = "";
                        row.Cells["QuantityPack"].Value = FrmAddReq.txtPack.Text;
                        row.Cells["Quantity"].Value = "";
                        row.Cells["Quantity"].Value = FrmAddReq.txtSale.Text;
                        row.Cells["Weight"].Value = "";
                        row.Cells["Weight"].Value = FrmAddReq.txtWeight.Text;
                        row.Cells["Type"].Value = type;
                        row.Cells["Detail"].Value = "";
                        row.Cells["Note"].Value = FrmAddReq.txtNote.Text;
                        row.Cells["Total"].Value = (Convert.ToDouble(row.Cells["Quantity"].Value) *
                            Convert.ToDouble(row.Cells["CostPrice"].Value)).ToString();

                        foreach (DataGridViewRow roww in FrmAddReq.dgvWeight.Rows)
                        {
                            foreach (DataGridViewCell cell in roww.Cells)
                            {
                                if (roww.Index < FrmAddReq.dgvWeight.RowCount - 1)
                                    if (!cell.Size.IsEmpty) row.Cells["Detail"].Value += cell.Value + "#";
                            }
                        }
                        SetDgvWeightH(row.Cells["Detail"].Value.ToString(), dataGridView3, type);
                        textBox11.Text = sumTotal("Total");
                    }
                }
            }
        }
예제 #2
0
        //ตรวจสอบประเภทน้ำหนักและรับข้อมูลน้ำหนักจาก Dialog เพิ่มข้อมูลรายละเอียดสินค้า
        private void checkType(String type, DataGridView dgv)
        {
            String ID = dgv.CurrentRow.Cells["ProductID"].Value.IsNullAsEmpty();//เก็บรหัสสินค้า
            String qtyp = dgv.CurrentRow.Cells["QuantityPack"].Value.IsNullAsEmpty();//เก็บจำนวนแพ็ค
            String qty = dgv.CurrentRow.Cells["Quantity"].Value.IsNullAsEmpty();//เก็บจำนวน
            String tw = dgv.CurrentRow.Cells["Detail"].Value.IsNullAsEmpty();//เก็บรายละเอียด

            String q = "";
            String d = "";
            String strNewProductionId = "";

            //foreach (var item in listFist)
            //{
            //    q = item.mquantity;
            //    d = item.mid;
            //    //dt.Rows.Add(item.id, item.mid, item.mname, item.mquantity, item.munit);
            //}
            DataTable table = ConvertListToDataTable(listFist);

            string str9 = dgv.CurrentRow.Cells[13].Value.IsNullAsEmpty();

            //DataTable dt = Class.Function.GetContentAsDataTable(dataGridView1);
            //DataRow[] r = table.Select("mid = '" + dgv.CurrentRow.Cells["Mid"].Value.IsNullAsEmpty() + "' ");//เก็บรหัสวัตถุดิบ
            DataRow[] r = table.Select("Mid = '" + dgv.CurrentRow.Cells["mid"].Value.IsNullAsEmpty() + "' and id = '" + dgv.CurrentRow.Cells["NewProductionId"].Value.IsNullAsEmpty() + "' ");//เก็บรหัสวัตถุดิบ

            for (int i = 0; i < r.Length; i++)
            {
                q = r[i]["mquantity"].IsNullAsEmpty();
                d = r[i]["mid"].IsNullAsEmpty();
                strNewProductionId = r[i]["id"].IsNullAsEmpty();
            }

            sumall = textBox12.Text.ToDouble();
            Double sum = 0;
            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                if (d == row.Cells["Mid"].Value.IsNullAsEmpty() && strNewProductionId == row.Cells["NewProductionId"].Value.IsNullAsEmpty())
                {
                    sum += (row.Cells["Quantity"].Value.ToDouble());//หาผลรวมของจำนวน
                }
            }
            foreach (DataGridViewRow row in dataGridView4.Rows)
            {
                if (d == row.Cells["Mid"].Value.IsNullAsEmpty() && strNewProductionId == row.Cells["NewProductionId"].Value.IsNullAsEmpty())
                {
                    sum += (row.Cells["Quantity"].Value.ToDouble());//หาผลรวมของจำนวน
                }
            }
            foreach (DataGridViewRow row in dgvMetLost.Rows)
            {
                if (d == row.Cells["Mid"].Value.IsNullAsEmpty() && strNewProductionId == row.Cells["NewProductionId"].Value.IsNullAsEmpty())
                {
                    sum += (row.Cells["Quantity"].Value.ToDouble());//หาผลรวมของจำนวน
                }
            }

            ProductionNew.frmAddReturn FrmAddReq = new ProductionNew.frmAddReturn(type, ID, tw, qtyp, qty, q, sum, 0);//เรียก Dailog เพิ่มรายละเอียดสินค้า
            FrmAddReq.ShowDialog();
            if (FrmAddReq.DialogResult == DialogResult.Yes)
            {
                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (row.Cells["ProductID"].Value.IsNullAsEmpty() == ID)//รหัสสินค้า
                    {
                        row.Cells["QuantityPack"].Value = "";
                        row.Cells["QuantityPack"].Value = FrmAddReq.txtPack.Text;//จำนวนแพ็ค
                        row.Cells["Quantity"].Value = "";
                        row.Cells["Quantity"].Value = FrmAddReq.txtSale.Text;//จำนวน
                        row.Cells["Weight"].Value = "";
                        row.Cells["Weight"].Value = FrmAddReq.txtWeight.Text;//น้ำหนัก
                        row.Cells["Type"].Value = type;//ประเภท
                        row.Cells["Detail"].Value = "";
                        row.Cells["Note"].Value = FrmAddReq.txtNote.Text;//หมายเหตุ
                        row.Cells["Total"].Value = ((row.Cells["Quantity"].Value.ToDouble()) *
                            (row.Cells["CostPrice"].Value.ToDouble())).IsNullAsEmpty();//ต้นทุน

                        foreach (DataGridViewRow roww in FrmAddReq.dgvWeight.Rows)
                        {
                            foreach (DataGridViewCell cell in roww.Cells)
                            {
                                if (roww.Index < FrmAddReq.dgvWeight.RowCount - 1)
                                    if (!cell.Size.IsEmpty) row.Cells["Detail"].Value += cell.Value + "#";
                            }
                        }
                        sumcost();
                    }
                }
                sumallw(d);
            }
        }