public int DeleteUserProdcutionDone(EmployeeProduction mFile)
        {
            //insert databse values
            SqlCommand deleteComm = new SqlCommand();

            deleteComm.Connection  = this.mConnectionUser;
            deleteComm.CommandType = CommandType.Text;

            deleteComm.Parameters.Add("@PMD_ProductionID", SqlDbType.NVarChar);
            deleteComm.Parameters.Add("@PMD_ShipmentID", SqlDbType.NVarChar);
            deleteComm.Parameters.Add("@PMD_ISBN", SqlDbType.NVarChar);
            deleteComm.Parameters.Add("@PMD_Format", SqlDbType.NVarChar);
            //deleteComm.Parameters.Add("@PMD_UserID", SqlDbType.NVarChar);
            //deleteComm.Parameters.Add("@PMD_Status", SqlDbType.NVarChar);

            deleteComm.Parameters["@PMD_ProductionID"].Value = mFile.ProductID;
            deleteComm.Parameters["@PMD_ShipmentID"].Value   = mFile.ShipmentID;
            deleteComm.Parameters["@PMD_ISBN"].Value         = mFile.ISBN;
            deleteComm.Parameters["@PMD_Format"].Value       = mFile.FormatName;
            //deleteComm.Parameters["@User_ID"].Value = mFile.UserID;
            //deleteComm.Parameters["@PMD_Status"].Value = mFile.Status;


            deleteComm.CommandText = "DELETE FROM EmployeeProduction WHERE ProductID=@PMD_ProductionID AND ShipmentID=@PMD_ShipmentID AND ISBN=@PMD_ISBN AND FormatName=@PMD_Format";
            int ans = deleteComm.ExecuteNonQuery();

            if (ans > 0)
            {
                return(ans);
            }
            else
            {
                return(0);
            }
        }
        public int AddUserProdcutionDone(EmployeeProduction mFile)
        {
            //insert databse values
            SqlCommand insetComm = new SqlCommand();

            insetComm.Connection  = this.mConnectionUser;
            insetComm.CommandType = CommandType.Text;

            insetComm.Parameters.Add("@EPD_ShpID", SqlDbType.BigInt);
            insetComm.Parameters.Add("@EPD_ShipmentID", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@EPD_ISBN", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@EPD_UID", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@EPD_PageCount", SqlDbType.Int);
            insetComm.Parameters.Add("@EPD_FormatName", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@EPD_DoneDate", SqlDbType.DateTime);
            insetComm.Parameters.Add("@EPD_Status", SqlDbType.NVarChar);


            insetComm.Parameters["@EPD_ShpID"].Value      = mFile.ProductID;
            insetComm.Parameters["@EPD_ShipmentID"].Value = mFile.ShipmentID;
            insetComm.Parameters["@EPD_ISBN"].Value       = mFile.ISBN;
            insetComm.Parameters["@EPD_UID"].Value        = mFile.UserID;
            insetComm.Parameters["@EPD_PageCount"].Value  = mFile.PageCount;
            insetComm.Parameters["@EPD_FormatName"].Value = mFile.FormatName;
            insetComm.Parameters["@EPD_DoneDate"].Value   = mFile.DoneDate;
            insetComm.Parameters["@EPD_Status"].Value     = mFile.Status;


            insetComm.CommandText = "INSERT INTO EmployeeProduction(ProductID,ShipmentID,ISBN,UserID,PageCount,FormatName,DoneDate,Status) VALUES (@EPD_ShpID,@EPD_ShipmentID,@EPD_ISBN,@EPD_UID,@EPD_PageCount,@EPD_FormatName,@EPD_DoneDate,@EPD_Status)";

            int ans = insetComm.ExecuteNonQuery();

            if (ans > 0)
            {
                return(ans);
            }
            else
            {
                return(0);
            }
        }
        //public int UpdateQRDone(EmployeeProduction mFile)
        //{
        //    //insert databse values
        //    SqlCommand updateComm = new SqlCommand();
        //    updateComm.Connection = this.mConnectionUser;
        //    updateComm.CommandType = CommandType.Text;

        //    updateComm.Parameters.Add("@EPD_ShpID", SqlDbType.BigInt);
        //    updateComm.Parameters.Add("@EPD_ShipmentID", SqlDbType.NVarChar);
        //    updateComm.Parameters.Add("@EPD_ISBN", SqlDbType.NVarChar);
        //    updateComm.Parameters.Add("@EPD_UID", SqlDbType.NVarChar);
        //    updateComm.Parameters.Add("@EPD_PageCount", SqlDbType.Int);
        //    updateComm.Parameters.Add("@EPD_FormatName", SqlDbType.NVarChar);
        //    updateComm.Parameters.Add("@EPD_DoneDate", SqlDbType.DateTime);
        //    updateComm.Parameters.Add("@EPD_Status", SqlDbType.NVarChar);


        //    updateComm.Parameters["@EPD_ShpID"].Value = mFile.ProductID;
        //    updateComm.Parameters["@EPD_ShipmentID"].Value = mFile.ShipmentID;
        //    updateComm.Parameters["@EPD_ISBN"].Value = mFile.ISBN;
        //    updateComm.Parameters["@EPD_UID"].Value = mFile.UserID;
        //    updateComm.Parameters["@EPD_PageCount"].Value = mFile.PageCount;
        //    updateComm.Parameters["@EPD_FormatName"].Value = mFile.FormatName;
        //    updateComm.Parameters["@EPD_DoneDate"].Value = mFile.DoneDate;
        //    updateComm.Parameters["@EPD_Status"].Value = mFile.Status;

        //    updateComm.CommandText = "UPDATE EmployeeProduction SET Status=@EPD_Status, DoneDate=@EPD_DoneDate WHERE ProductID=@EPD_ShpID AND ShipmentID=@EPD_ShipmentID AND ISBN=@EPD_ISBN AND PageCount=@EPD_PageCount AND FormatName=@EPD_FormatName";

        //    int ans = updateComm.ExecuteNonQuery();
        //    if (ans > 0)
        //    {
        //        return ans;
        //    }
        //    else
        //    {
        //        return 0;
        //    }
        //}

        public int UpdateProductionStatus(EmployeeProduction mFile)
        {
            //insert databse values
            SqlCommand updateComm = new SqlCommand();

            updateComm.Connection  = this.mConnectionUser;
            updateComm.CommandType = CommandType.Text;

            updateComm.Parameters.Add("@EPD_ShpID", SqlDbType.BigInt);
            updateComm.Parameters.Add("@EPD_ShipmentID", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@EPD_ISBN", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@EPD_UID", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@EPD_FormatName", SqlDbType.NVarChar);
            //updateComm.Parameters.Add("@EPD_DoneDate", SqlDbType.DateTime);
            updateComm.Parameters.Add("@EPD_Status", SqlDbType.NVarChar);


            updateComm.Parameters["@EPD_ShpID"].Value      = mFile.ProductID;
            updateComm.Parameters["@EPD_ShipmentID"].Value = mFile.ShipmentID;
            updateComm.Parameters["@EPD_ISBN"].Value       = mFile.ISBN;
            updateComm.Parameters["@EPD_UID"].Value        = mFile.UserID;
            updateComm.Parameters["@EPD_FormatName"].Value = mFile.FormatName;
            //updateComm.Parameters["@EPD_DoneDate"].Value = mFile.DoneDate;
            updateComm.Parameters["@EPD_Status"].Value = mFile.Status;

            updateComm.CommandText = "UPDATE EmployeeProduction SET Status=@EPD_Status WHERE ProductID=@EPD_ShpID AND ShipmentID=@EPD_ShipmentID AND ISBN=@EPD_ISBN AND FormatName=@EPD_FormatName";

            int ans = updateComm.ExecuteNonQuery();

            if (ans > 0)
            {
                return(ans);
            }
            else
            {
                return(0);
            }
        }
예제 #4
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);
                }
            }
        }