public int AddTAT(TATDelivery mTAT)
        {
            //insert databse values
            SqlCommand insetComm = new SqlCommand();

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

            insetComm.Parameters.Add("@TAT_ShpID", SqlDbType.BigInt);
            insetComm.Parameters.Add("@TAT_ShipmentID", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@TAT_ISBN", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@TAT_Priority", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@TAT_Format", SqlDbType.NVarChar);
            insetComm.Parameters.Add("@TAT_PubDate", SqlDbType.DateTime);
            insetComm.Parameters.Add("@TAT_TATDate", SqlDbType.DateTime);
            insetComm.Parameters.Add("@TAT_DateOfAllocation", SqlDbType.DateTime);
            insetComm.Parameters.Add("@TAT_TeamName", SqlDbType.NVarChar);

            insetComm.Parameters["@TAT_ShpID"].Value            = mTAT.ShpID;
            insetComm.Parameters["@TAT_ShipmentID"].Value       = mTAT.ShipmentID;
            insetComm.Parameters["@TAT_ISBN"].Value             = mTAT.ISBN;
            insetComm.Parameters["@TAT_Priority"].Value         = mTAT.PriorityName;
            insetComm.Parameters["@TAT_Format"].Value           = mTAT.Format;
            insetComm.Parameters["@TAT_PubDate"].Value          = mTAT.PubDate;
            insetComm.Parameters["@TAT_TATDate"].Value          = mTAT.TATDate;
            insetComm.Parameters["@TAT_DateOfAllocation"].Value = mTAT.DateOfAllocation;
            insetComm.Parameters["@TAT_TeamName"].Value         = mTAT.TeamName;

            insetComm.CommandText = "insert into TATDelivery(ShpID,ShipmentID,ISBN,PriorityName,FormatName,PubDate,TATDate,DateOfAllocation,Team)values(@TAT_ShpID,@TAT_ShipmentID,@TAT_ISBN,@TAT_Priority,@TAT_Format,@TAT_PubDate,@TAT_TATDate,@TAT_DateOfAllocation,@TAT_TeamName)";

            int ans = insetComm.ExecuteNonQuery();

            if (ans > 0)
            {
                return(ans);
            }
            else
            {
                return(0);
            }
        }
        public int ClearTAT(TATDelivery mTAT)
        {
            //insert databse values
            SqlCommand updateComm = new SqlCommand();

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

            updateComm.Parameters.Add("@TAT_ShpID", SqlDbType.BigInt);
            updateComm.Parameters.Add("@TAT_ShipmentID", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@TAT_ISBN", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@TAT_Priority", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@TAT_Format", SqlDbType.NVarChar);
            updateComm.Parameters.Add("@TAT_PubDate", SqlDbType.DateTime);
            updateComm.Parameters.Add("@TAT_TATDate", SqlDbType.DateTime);
            updateComm.Parameters.Add("@DateOfAllocation", SqlDbType.DateTime);

            updateComm.Parameters["@TAT_ShpID"].Value        = mTAT.ShpID;
            updateComm.Parameters["@TAT_ShipmentID"].Value   = mTAT.ShipmentID;
            updateComm.Parameters["@TAT_ISBN"].Value         = mTAT.ISBN;
            updateComm.Parameters["@TAT_Priority"].Value     = mTAT.PriorityName;
            updateComm.Parameters["@TAT_Format"].Value       = mTAT.Format;
            updateComm.Parameters["@TAT_PubDate"].Value      = mTAT.PubDate;
            updateComm.Parameters["@TAT_TATDate"].Value      = mTAT.TATDate;
            updateComm.Parameters["@DateOfAllocation"].Value = mTAT.DateOfAllocation;

            updateComm.CommandText = "delete from TATDelivery where ShipmentID=@TAT_ShipmentID AND ISBN=@TAT_ISBN AND ShpID=@TAT_ShpID";

            int ans = updateComm.ExecuteNonQuery();

            if (ans > 0)
            {
                return(ans);
            }
            else
            {
                return(0);
            }
        }
Exemple #3
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);
                }
            }
        }