Beispiel #1
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            try{
                //Message for Error when Shipment Fied is empty
                if (cmbShipment.Text.ToString() == "")
                {
                    MessageBox.Show("Please select a Shipment", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    if (cbmSAllFiles.Checked == true && cmbShipment.Text.ToString() != "")
                    {
                        //Initialize Message Result
                        DialogResult result;
                        result = MessageBox.Show("Do you really want to delete \"" + cmbShipment.Text + "\"?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            //Create Object From ShipmetDetail Object
                            ShipmetDetail              mShipment                   = new ShipmetDetail();
                            ShipmentHeader             mShipmentHeader             = new ShipmentHeader();
                            ShipmentDetailFormats      mShipmentDetailFormats      = new ShipmentDetailFormats();
                            TATDelivery                mTATDelivery                = new TATDelivery();
                            ProductionManagementDetail mProductionManagementDetail = new ProductionManagementDetail();
                            ProductionManagementHeader mProductionManagementHeader = new ProductionManagementHeader();


                            // Assign Shipment Delete Interface data to mShipmentID
                            String mShipmentID = cmbShipment.Text.ToString();


                            //Create Services
                            ShipmentDetailMng             mShipmentMng                   = new ShipmentDetailMng(conn);
                            ShipmentHeaderMng             mShipmentHeaderMng             = new ShipmentHeaderMng(conn);
                            ShipmentDetailFormatsMng      mShipmentDetailFormatsMng      = new ShipmentDetailFormatsMng(conn);
                            TATDeliveryMng                mTATDeliveryMng                = new TATDeliveryMng(conn);
                            ProductionManagementDetailMng mProductionManagementDetailMng = new ProductionManagementDetailMng(conn);
                            ProductionManagementHeaderMng mProductionManagementHeaderMng = new ProductionManagementHeaderMng(conn);

                            mShipmentDetailFormatsMng.DeleteShimpentFormats(mShipmentID);
                            mShipmentMng.DeleteShipment(mShipmentID);
                            mShipmentHeaderMng.DeleteShipmentHeader(mShipmentID);



                            MessageBox.Show("\"" + cmbShipment.Text + "\" successfully deleted..!", " Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            frm_DCDImport DCDFrm = new frm_DCDImport();
                            RefreshData();
                            this.Dispose();
                        }
                        else
                        {
                            this.Dispose();
                        }
                    }

                    else if (cmbISBN.Text != "" && cmbShipment.Text.ToString() != "")
                    {
                        //Initialize Message Result
                        DialogResult result;
                        result = MessageBox.Show("Do you really want to delete ISBN " + cmbISBN.Text + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            //Create Object From ShipmetDetail Object
                            ShipmetDetail         mShipmentISBN          = new ShipmetDetail();
                            ShipmetDetail         mShipment              = new ShipmetDetail();
                            ShipmentDetailFormats mShipmentDetailFormats = new ShipmentDetailFormats();



                            // Assign Shipment Delete Interface data to mShipmentwithISBN Object
                            mShipment.ID       = cmbShipment.Text;
                            mShipmentISBN.ISBN = cmbISBN.Text;


                            ShipmentDetailMng        mShipmentMng              = new ShipmentDetailMng(conn);
                            ShipmentDetailMng        mShipmentMngShpID         = new ShipmentDetailMng(conn);
                            ShipmentDetailFormatsMng mShipmentDetailFormatsMng = new ShipmentDetailFormatsMng(conn);

                            if (mShipmentMng.DeleteShipmentFromID(mShipmentISBN, mShipment) > 0)
                            {
                                MessageBox.Show("ISBN " + mShipmentISBN.ISBN + " successfully deleted..!", "ISBN Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                RefreshData();
                                this.Dispose();
                            }
                        }
                        else if (result == DialogResult.No)
                        {
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2146232060)
                {
                    MessageBox.Show("This shipment is already in production!", "Cannot Delete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Error" + ex.Message);
                }
            }
        }
Beispiel #2
0
        private void btnRemoveUID_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result;
                int          rowIndex = dataGridAfterAssignedUID.CurrentRow.Index;

                if (dataGridAfterAssignedUID.Rows[rowIndex].Cells[7].Value.ToString() == "Process By User")
                {
                    String ISBN = dataGridAfterAssignedUID.Rows[rowIndex].Cells[2].Value.ToString();

                    result = MessageBox.Show("Do you really want to remove User ID from ISBN: " + ISBN + "?", "Remove User from Assign File", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        QRDetail                   mQRD                   = new QRDetail();
                        QRHeader                   mQRH                   = new QRHeader();
                        EmployeeProduction         mEMP                   = new EmployeeProduction();
                        ProductionManagementDetail mProductionDtl         = new ProductionManagementDetail();
                        ProductionManagementHeader mProductionHdr         = new ProductionManagementHeader();
                        ShipmentDetailFormats      mShipmentDetailFormats = new ShipmentDetailFormats();
                        ProductionStatus           mLog                   = new ProductionStatus();

                        //initilize values for QR Detail to delete
                        mQRD.ProductID  = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mQRD.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mQRD.ISBN       = ISBN;
                        mQRD.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();

                        //initilize values for QR Header to delete
                        mQRH.ProductID  = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mQRH.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mQRH.ISBN       = ISBN;
                        mQRH.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();

                        //initilize values for Employee Production to delete
                        mEMP.ProductID  = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mEMP.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mEMP.ISBN       = ISBN;
                        mEMP.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();
                        mEMP.Status     = "Complete By User";

                        //initilize values for Production Detail to delete
                        mProductionDtl.ShpID      = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mProductionDtl.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mProductionDtl.ISBN       = ISBN;
                        mProductionDtl.Format     = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();

                        //initilize values for Production Detail Header to delete
                        mProductionHdr.ShpID      = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mProductionHdr.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mProductionHdr.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();

                        //initilize values for Detail Format to delete
                        mShipmentDetailFormats.ShpID      = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mShipmentDetailFormats.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mShipmentDetailFormats.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();

                        //Production Status Log Value
                        mLog.ProductID  = int.Parse(dataGridAfterAssignedUID.Rows[rowIndex].Cells[0].Value.ToString());
                        mLog.ShipmentID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[1].Value.ToString();
                        mLog.ISBN       = dataGridBeforeAssignedUID.Rows[rowIndex].Cells[2].Value.ToString();
                        mLog.StartDate  = DateTime.Now;
                        mLog.FormatName = dataGridAfterAssignedUID.Rows[rowIndex].Cells[3].Value.ToString();
                        mLog.UserID     = lblCUID.Text;
                        String aUID = dataGridAfterAssignedUID.Rows[rowIndex].Cells[4].Value.ToString();
                        mLog.Status = "Removed assigned User " + aUID + " from Assgned Production by System Access User " + lblCUID.Text;

                        QRDetailMng                   mQRDMng                   = new QRDetailMng(conn);
                        QRHeaderMng                   mQRHMng                   = new QRHeaderMng(conn);
                        EmployeeProductionMng         mEPMMng                   = new EmployeeProductionMng(conn);
                        ProductionManagementDetailMng mShipmentDetailMng        = new ProductionManagementDetailMng(conn);
                        ProductionManagementHeaderMng mProductionHdrMng         = new ProductionManagementHeaderMng(conn);
                        ShipmentDetailFormatsMng      mShipmentDetailFormatsMng = new ShipmentDetailFormatsMng(conn);

                        // Delete Production Manegement Detail
                        if (mShipmentDetailMng.DeleteAssignedProductionManagementDetail(mProductionDtl) > 0)
                        {
                            // Delete Production Manegement Header
                            mProductionHdrMng.DeleteProductionManagementHeader(mProductionHdr);

                            // Delete QR Detail
                            if (mQRDMng.DeleteQRDetail(mQRD) > 0)
                            {
                                // Delete QR Header
                                mQRHMng.DeleteQRHeader(mQRH);
                            }
                            // Delete Employee Production
                            mEPMMng.DeleteUserProdcutionDone(mEMP);

                            // Update Employee Shipment Detail Formats to Not Assign
                            mShipmentDetailFormatsMng.UpdateProductionOnToBeAssignFormatFile(mShipmentDetailFormats);

                            MessageBox.Show("Selected assigned User successfully cleared from File..!", "Assigned File Clear", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            //Production Log table
                            new ProductionStatusLogMng(this.conn).AddProdustionStatus(mLog);

                            RefreshData();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("This file is already in process by User. \nFirst modify status before remove User ID.", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    btnModifyUID.Focus();
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147467261)
                {
                    MessageBox.Show("First select a file to remove User ID.", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cmbShipment.Focus();
                }
                else
                {
                    MessageBox.Show("Error" + ex.Message);
                }
            }
        }