Ejemplo n.º 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == comboBox2.Text)
     {
         MessageBox.Show("Dữ liệu Warehouse không được trùng");
     }
     else
     {
         if (dataGridView1.Rows.Count >= 2)
         {
             bllss4.insertIntoOrdersAdj(TranID, int.Parse(comboBox1.SelectedValue.ToString()), int.Parse(comboBox2.SelectedValue.ToString()), dateTimePicker1.Value.ToString());
             DataTable dt = bllss4.getIDOrders();
             dt.Rows[0][0].ToString();
             int OrderId = int.Parse(dt.Rows[0][0].ToString());
             for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
             {
                 DataTable dt1        = bllss4.getIdByPartName(dataGridView1.Rows[i].Cells["PartName"].Value.ToString());
                 int       PartID     = int.Parse(dt1.Rows[0][0].ToString());
                 string    BathNumber = dataGridView1.Rows[i].Cells["BatchNumber"].Value.ToString();
                 float     Amount     = float.Parse(dataGridView1.Rows[i].Cells["Amount"].Value.ToString());
                 bllss4.insertIntoOrderItems(OrderId, PartID, BathNumber, Amount);
                 //bllss4.updateOrderItemsByTranAndBatch(Amount, BathNumber, int.Parse(comboBox1.SelectedValue.ToString()));
             }
             MessageBox.Show("Thêm dữ liệu thành công");
         }
         else
         {
             MessageBox.Show("Bạn cần thêm dữ liệu vào bảng");
         }
     }
 }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int Source = 0;

            if (comboBox1.SelectedValue.ToString() == "1")
            {
                Source = 1;
            }
            if (comboBox1.SelectedValue.ToString() == "2")
            {
                Source = 2;
            }
            if (comboBox1.SelectedValue.ToString() == "3")
            {
                Source = 3;
            }
            if (comboBox1.SelectedValue.ToString() == "4")
            {
                Source = 4;
            }

            if (comboBox1.SelectedValue.ToString() == "1" && comboBox1.SelectedValue.ToString() == Source.ToString())
            {
                Source = 2;
            }
            if (comboBox1.SelectedValue.ToString() == "2" && comboBox1.SelectedValue.ToString() == Source.ToString())
            {
                Source = 3;
            }
            if (comboBox1.SelectedValue.ToString() == "3" && comboBox1.SelectedValue.ToString() == Source.ToString())
            {
                Source = 4;
            }
            if (comboBox1.SelectedValue.ToString() == "4" && comboBox1.SelectedValue.ToString() == Source.ToString())
            {
                Source = 1;
            }

            if (dataGridView1.Rows.Count >= 2)
            {
                bllss4.insertIntoOrders(TranID, int.Parse(comboBox1.SelectedValue.ToString()),
                                        Source, int.Parse(comboBox2.SelectedValue.ToString()), dateTimePicker1.Value.ToString());
                DataTable dt      = bllss4.getIDOrders();
                int       OrderId = int.Parse(dt.Rows[0][0].ToString());
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    DataTable dt1        = bllss4.getIdByPartName(dataGridView1.Rows[i].Cells["PartName"].Value.ToString());
                    int       PartID     = int.Parse(dt1.Rows[0][0].ToString());
                    string    BathNumber = dataGridView1.Rows[i].Cells["BatchNumber"].Value.ToString();
                    float     Amount     = float.Parse(dataGridView1.Rows[i].Cells["Amount"].Value.ToString());
                    bllss4.insertIntoOrderItems(OrderId, PartID, BathNumber, Amount);
                    bllss4.updateParts(PartID, Amount);
                }
                MessageBox.Show("Thêm dữ liệu thành công");
            }
            else
            {
                MessageBox.Show("Bạn cần thêm dữ liệu vào bảng");
            }
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            if (comboBox1.SelectedItem != null)
            {
                dt = bllss4.getIdByPartName(comboBox1.SelectedItem.ToString());
            }
            else
            {
                dt = bllss4.getIdByPartName(partName);
            }

            DataTable dtSource = new DataTable();

            if (comboBox4.SelectedItem != null)
            {
                dtSource = bllss4.getIdByWareHouse(comboBox4.SelectedItem.ToString());
            }
            else
            {
                dtSource = bllss4.getIdByWareHouse(source);
            }

            DataTable dtDes = new DataTable();

            if (comboBox5.SelectedItem != null)
            {
                dtDes = bllss4.getIdByWareHouse(comboBox5.SelectedItem.ToString());
            }
            else
            {
                dtDes = bllss4.getIdByWareHouse(destination);
            }

            DataTable dtTran = new DataTable();

            if (comboBox2.SelectedItem != null)
            {
                dtTran = bllss4.getIdByTranSactionName(comboBox2.SelectedItem.ToString());
            }
            else
            {
                dtTran = bllss4.getIdByTranSactionName(transactionType);
            }

            int PartID   = int.Parse(dt.Rows[0][0].ToString());
            int SourceID = int.Parse(dtSource.Rows[0][0].ToString());
            int DesId    = int.Parse(dtDes.Rows[0][0].ToString());
            int TranId   = int.Parse(dtTran.Rows[0][0].ToString());
            int amountr  = int.Parse(txtAmount.Text);



            if (comboBox1.Text.Trim() != "" && comboBox2.Text.Trim() != "" && comboBox4.Text.Trim() != "" && comboBox5.Text.Trim() != "" && txtAmount.Text.Trim() != "")
            {
                bool check1 = bllss4.update(PartID, amountr, orderitemid);
                bool check2 = bllss4.update2(SourceID, DesId, TranId, ordersid);
                if (check1 == true && check2 == true)
                {
                    MessageBox.Show("Cap nhat thanh cong");
                }
                else
                {
                    MessageBox.Show("Cap nhat that bai");
                }
            }
            else
            {
                MessageBox.Show("Bạn cần điền đủ thông tin");
            }
        }