示例#1
0
        private void btnChoose_Click(object sender, EventArgs e)
        {
            try
            {
                if (rdrYesUse.Checked == true)
                {
                    CopyGridView copyGrid = new CopyGridView();
                    copyGrid.copyDataGridViewNotDelete(dgvAddOutDevice, dgvListDevice);

                    dgvListDevice.Columns.Add("Ma_TS_Repair", "Vật tư cần sửa chữa");

                    foreach (DataGridViewRow row in dgvRepairDevice.Rows)
                    {
                        Boolean CheckRow = Convert.ToBoolean(row.Cells["Select"].Value);
                        if (CheckRow)
                        {
                            string MTS = row.Cells["Ma_TS"].Value.ToString();
                            foreach (DataGridViewRow row2 in dgvListDevice.Rows)
                            {
                                row2.Cells["Ma_TS_Repair"].Value = MTS;
                            }
                        }
                    }


                    AntiDuplicated antiDuplicated = new AntiDuplicated();
                    antiDuplicated.AntiColumnDuplicate(dgvListDevice);

                    string ColumnName = dgvAddOutDevice.Columns["Select"].Name.ToString();
                    AutoComplete.AutoUnselectAll(dgvAddOutDevice, ColumnName);

                    foreach (DataGridViewRow row in dgvRepairDevice.Rows)
                    {
                        Boolean CheckRow = Convert.ToBoolean(row.Cells["Select"].Value);
                        if (CheckRow)
                        {
                            int n = row.Index;
                            dgvRepairDevice.Rows.RemoveAt(n);
                        }
                    }


                    btnFinalTransfer_Click(this, new EventArgs());
                }
                else if (rdrNoUse.Checked == true)
                {
                    CopyGridView copyGrid = new CopyGridView();
                    copyGrid.CopyDataGridView(dgvRepairDevice, dgvListDevice);

                    foreach (DataGridViewRow row in dgvRepairDevice.Rows)
                    {
                        Boolean CheckRow = Convert.ToBoolean(row.Cells["Select"].Value);
                        if (CheckRow)
                        {
                            int n = row.Index;
                            dgvRepairDevice.Rows.RemoveAt(n);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
文件: Main.cs 项目: dovanan95/QLTS
        private void btnApproveRepair_Click(object sender, EventArgs e)
        {
            try
            {
                AutoStickDuplicatedMTS();

                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    Boolean CheckRow = Convert.ToBoolean(row.Cells["SelectRepair"].Value);
                    if (CheckRow)
                    {
                        AutoTask.UpdateApprovedOfBB(row.Cells["So_Bien_Ban"].Value.ToString());
                        AutoTask.BufferClear(Convert.ToInt32(row.Cells["Ma_TS"].Value));
                        if (row.Cells["vat_tu_xuat"].Value.ToString() != "")
                        {
                            AutoTask.BufferClear(Convert.ToInt32(row.Cells["vat_tu_xuat"].Value));
                        }
                        else if (row.Cells["vat_tu_xuat"].Value.ToString() == "")
                        {
                        }


                        string        strUpdate = "UPDATE Sua_chua SET Approved = 1 WHERE Ma_TS = '" + row.Cells["Ma_TS"].Value.ToString() + "'";
                        OracleCommand cmdUpdate = new OracleCommand();
                        cmdUpdate.CommandType = CommandType.Text;
                        cmdUpdate.CommandText = strUpdate;
                        cmdUpdate.Connection  = con;
                        con.Open();
                        cmdUpdate.ExecuteNonQuery();
                        con.Close();
                    }
                }

                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    Boolean ChkRow = Convert.ToBoolean(row.Cells["SelectRepair"].Value);


                    if (ChkRow == true)
                    {
                        string VTX = row.Cells["Vat_tu_xuat"].Value.ToString();
                        if (VTX != "")
                        {
                            string        strRepair = "INSERT INTO Ngoai_Kho (Ma_TS, ID_User, Latest_Day_Out, So_BB) VALUES (:Ma_TS, :ID_User, CURRENT_DATE, :SoBB)";
                            OracleCommand cmdRepair = new OracleCommand();
                            cmdRepair.Connection  = con;
                            cmdRepair.CommandType = CommandType.Text;
                            cmdRepair.CommandText = strRepair;
                            cmdRepair.Parameters.Add(new OracleParameter("Ma_TS", row.Cells["Vat_tu_xuat"].Value.ToString()));
                            cmdRepair.Parameters.Add(new OracleParameter("ID_User", row.Cells["USER_ID"].Value.ToString()));
                            cmdRepair.Parameters.Add(new OracleParameter("SoBB", row.Cells["So_Bien_Ban"].Value.ToString()));
                            //cmdRepair.Parameters.Add(new OracleParameter("clDate", row.Cells["Ngay_update"].Value.ToString()));

                            con.Open();
                            cmdRepair.ExecuteNonQuery();
                            con.Close();
                        }
                        else if (VTX == "")
                        {
                        }
                    }
                }

                foreach (DataGridViewRow row in dataGridView2.Rows)
                {
                    Boolean ChkRow = Convert.ToBoolean(row.Cells["SelectRepair"].Value);
                    if (ChkRow)
                    {
                        string        strRepair2 = "INSERT INTO Ngoai_Kho (Ma_TS, ID_User, Latest_Day_Out, So_BB) VALUES (:Ma_TS, :ID_User, CURRENT_DATE, :So_BB)";
                        OracleCommand cmdRepair2 = new OracleCommand();
                        cmdRepair2.Connection  = con;
                        cmdRepair2.CommandType = CommandType.Text;
                        cmdRepair2.CommandText = strRepair2;
                        cmdRepair2.Parameters.Add(new OracleParameter("Ma_TS", row.Cells["Ma_TS"].Value.ToString()));
                        cmdRepair2.Parameters.Add(new OracleParameter("ID_User", row.Cells["USER_ID"].Value.ToString()));
                        //cmdRepair2.Parameters.Add("clDate", row.Cells["Ngay_update"].Value.ToString());
                        cmdRepair2.Parameters.Add(new OracleParameter("So_BB", row.Cells["So_Bien_Ban"].Value.ToString()));
                        con.Open();
                        cmdRepair2.ExecuteNonQuery();
                        con.Close();
                    }
                }
                string tableName = "NGOAI_KHO";
                string fieldName = "MA_TS";

                AntiDuplicated antiDuplicated = new AntiDuplicated();
                antiDuplicated.DeleteDuplicatedRow(tableName, fieldName);

                OutStorageLoad();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }