Ejemplo n.º 1
0
        private void DataGrdVuUserQueries_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DataGrdVuUserQueries.Rows.Count > 0)
            {
                /* Open new Form of Working and pass queryId to the working */

                /* MessageBox.Show("Data Row selected : \n" +
                 *   DataGrdVuUserQueries.SelectedRows[0].Cells["AssignedDate"].Value.ToString() + "\n" +
                 *   DataGrdVuUserQueries.SelectedRows[0].Cells["QueryId"].Value.ToString() + "\n" +
                 *   DataGrdVuUserQueries.SelectedRows[0].Cells["Location"].Value.ToString() + "\n" +
                 *   DataGrdVuUserQueries.SelectedRows[0].Cells["fromDate"].Value.ToString() + "\n" +
                 *   DataGrdVuUserQueries.SelectedRows[0].Cells["toDate"].Value.ToString() + "\n" );*/
                if (openWorkingPage)
                {
                    FrmQueryWorkingPage frmQueryWorkingPage = new FrmQueryWorkingPage(DataGrdVuUserQueries.SelectedRows[0].Cells["QueryId"].Value.ToString());
                    Hide();
                    frmQueryWorkingPage.ShowDialog();
                    Show();
                }
            }
            else
            {
                MessageBox.Show("Please load Queries First", "Load Queries", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 2
0
 private void DataGrdVuUserQueries_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (DataGrdVuUserQueries.Rows.Count > 0)
     {
         /* Open new Form of Working and pass queryId to the working */
         try
         {
             Debug.WriteLine("Data Row selected For Working Itinerary: \n" +
                             DataGrdVuUserQueries.SelectedRows[0].Cells["AssignedDate"].Value.ToString() + "\n" +
                             DataGrdVuUserQueries.SelectedRows[0].Cells["QueryId"].Value.ToString() + "\n" +
                             DataGrdVuUserQueries.SelectedRows[0].Cells["Location"].Value.ToString() + "\n" +
                             DataGrdVuUserQueries.SelectedRows[0].Cells["fromDate"].Value.ToString() + "\n" +
                             DataGrdVuUserQueries.SelectedRows[0].Cells["toDate"].Value.ToString() + "\n");
         }
         catch (Exception errSelection)
         {
             Debug.WriteLine("Error in selecting rows. Err Msg = " + errSelection.Message);
             return;
         }
         if (radioButtonWorkingItinary.Checked)
         {
             FrmQueryWorkingPage frmQueryWorkingPage = new FrmQueryWorkingPage(DataGrdVuUserQueries.SelectedRows[0].Cells["QueryId"].Value.ToString());
             Hide();
             frmQueryWorkingPage.ShowDialog();
             Show();
         }
         else if (radioButtonWorkingVouchers.Checked)
         //else if (radioButtonCompletedItinerary.Checked)/* this line needs to be deleted after testing */
         {
             FrmVouchersWorkingOptionPage frmVouchersWorkingOptionPage = new FrmVouchersWorkingOptionPage(DataGrdVuUserQueries.SelectedRows[0].Cells["QueryId"].Value.ToString());
             Hide();
             frmVouchersWorkingOptionPage.ShowDialog();
             Show();
         }
         else
         {
             Debug.WriteLine("Usefull radio button not selected. thus not doing anything\n");
         }
         DataGrdVuUserQueriesLoad();
     }
     else
     {
         MessageBox.Show("Please load Queries First", "Load Queries", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Ejemplo n.º 3
0
        private void DataGrdVuAdminQueries_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DataGrdVuAdminQueries.Rows.Count > 0)
            {
                /* Open new Form of Working and pass queryId to the working */
                if (openVoucherPage)
                {
                    MessageBox.Show("Generating VOUCHERS FOR : \n" +
                                    DataGrdVuAdminQueries.SelectedRows[0].Cells["AssignedDate"].Value.ToString() + "\n" +
                                    DataGrdVuAdminQueries.SelectedRows[0].Cells["QueryId"].Value.ToString() + "\n" +
                                    DataGrdVuAdminQueries.SelectedRows[0].Cells["Location"].Value.ToString() + "\n" +
                                    DataGrdVuAdminQueries.SelectedRows[0].Cells["fromDate"].Value.ToString() + "\n" +
                                    DataGrdVuAdminQueries.SelectedRows[0].Cells["toDate"].Value.ToString() + "\n");
                    FrmQueryWorkingPage frmQueryWorkingPage = new FrmQueryWorkingPage(DataGrdVuAdminQueries.SelectedRows[0].Cells["QueryId"].Value.ToString());
                    Hide();
                    frmQueryWorkingPage.ShowDialog();
                    Show();
                }
                else
                {
                    //MessageBox.Show("Generating ITINERARY FOR : \n" +
                    //DataGrdVuAdminQueries.SelectedRows[0].Cells["AssignedDate"].Value.ToString() + "\n" +
                    //DataGrdVuAdminQueries.SelectedRows[0].Cells["QueryId"].Value.ToString() + "\n" +
                    //DataGrdVuAdminQueries.SelectedRows[0].Cells["Location"].Value.ToString() + "\n" +
                    //DataGrdVuAdminQueries.SelectedRows[0].Cells["fromDate"].Value.ToString() + "\n" +
                    //DataGrdVuAdminQueries.SelectedRows[0].Cells["toDate"].Value.ToString() + "\n");
                    if (saveFileDialogItinerary.ShowDialog() == DialogResult.OK)
                    {
                        /* file selected */
                        Debug.WriteLine("OUT FILE SELECTED : " + saveFileDialogItinerary.FileName);
                    }
                    else
                    {
                        Debug.WriteLine("File not selected thus returning");
                        return;
                    }

                    /* get all information from database regarding this queryid*/
                    string mysqlQueryString = "SELECT * FROM `queries` WHERE `queryid` = " + DataGrdVuAdminQueries.SelectedRows[0].Cells["QueryId"].Value.ToString();
                    try
                    {
                        frmMysqlConnection.Open();
                    }
                    catch (Exception errConnOpen)
                    {
                        MessageBox.Show("Error in opening mysql connection because : " + errConnOpen.Message);
                        return;
                    }

                    DataSet          queryDataset     = new DataSet();
                    MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mysqlQueryString, frmMysqlConnection);
                    mySqlDataAdapter.Fill(queryDataset, "SELECTED_QUERY");
                    mysqlQueryString = "SELECT * FROM `queryworkinghotel` WHERE `queryid` = " + DataGrdVuAdminQueries.SelectedRows[0].Cells["QueryId"].Value.ToString();
                    mySqlDataAdapter.SelectCommand.CommandText = mysqlQueryString;
                    mySqlDataAdapter.Fill(queryDataset, "QUERY_HOTEL_INFO");

                    /* Generate pdf file for ITINERARY */
                    Int32          yCordinateUtilized = 0;
                    PdfDocument    pdfDocument        = new PdfDocument();
                    PdfPage        pdfPage            = pdfDocument.AddPage();
                    XGraphics      xGraphics          = XGraphics.FromPdfPage(pdfPage);
                    XFont          xFontBody          = new XFont("Times New Roman", 11, XFontStyle.Regular);
                    XFont          xFontHeader        = new XFont("Times New Roman", 15, XFontStyle.Bold);
                    XTextFormatter xTextFormatter     = new XTextFormatter(xGraphics);
                    XImage         image = Properties.Resources.imageExcursionHolidaysLetterHead;
                    xGraphics.DrawImage(image, 0, 0, 605, 95);
                    yCordinateUtilized += 100;
                    string fileContent;
                    double noOfnights = (DateTime.Parse(DataGrdVuAdminQueries.SelectedRows[0].Cells["toDate"].Value.ToString()) -
                                         DateTime.Parse(DataGrdVuAdminQueries.SelectedRows[0].Cells["fromDate"].Value.ToString())).TotalDays;
                    fileContent = DataGrdVuAdminQueries.SelectedRows[0].Cells["Location"].Value.ToString() + " Tour\r\n" +
                                  noOfnights.ToString() + " Nights and " + (noOfnights + 1).ToString() + " Days";
                    XRect xRect = new XRect(40, yCordinateUtilized, 560, 40);
                    yCordinateUtilized += 40;
                    xGraphics.DrawRectangle(XBrushes.White, xRect);
                    xTextFormatter.Alignment = XParagraphAlignment.Center;
                    xTextFormatter.DrawString(fileContent, xFontHeader, XBrushes.Black, xRect, XStringFormat.TopLeft);

                    foreach (DataRow item in queryDataset.Tables["QUERY_HOTEL_INFO"].Rows)
                    {
                        fileContent         = "For Day " + item["dayno"].ToString() + " Hotel selected in city " + item["city"].ToString() + " is " + item["hotel"].ToString();
                        fileContent        += " room " + item["roomno"].ToString() + " with meal plan " + item["mealplan"].ToString() + " having " + item["extrabed"].ToString();
                        fileContent        += " extra bed and " + item["extrameal"].ToString() + " extra meal is at rate " + item["price"].ToString();
                        xRect               = new XRect(40, yCordinateUtilized, 560, 40);
                        yCordinateUtilized += 40;
                        xGraphics.DrawRectangle(XBrushes.White, xRect);
                        xTextFormatter.Alignment = XParagraphAlignment.Left;
                        xTextFormatter.DrawString(fileContent, xFontBody, XBrushes.Black, xRect, XStringFormat.TopLeft);
                    }
                    try
                    {
                        /* try to save file */
                        pdfDocument.Save(saveFileDialogItinerary.FileName);
                    }
                    catch (Exception errSave)
                    {
                        MessageBox.Show("Error in saving file " + saveFileDialogItinerary.FileName + " because " + errSave.Message);
                        Debug.WriteLine("Error in saving file " + saveFileDialogItinerary.FileName + " because " + errSave.Message);
                    }
                    finally
                    {
                        pdfDocument.Close();
                    }
                    MySqlCommand     mySqlCommand     = frmMysqlConnection.CreateCommand();
                    MySqlTransaction mySqlTransaction = frmMysqlConnection.BeginTransaction();
                    mySqlCommand.Connection  = frmMysqlConnection;
                    mySqlCommand.Transaction = mySqlTransaction;
                    mySqlCommand.CommandType = CommandType.Text;
                    mySqlCommand.CommandText = "UPDATE `queries` SET " +
                                               "`querylastupdatetime` = NOW(), " +
                                               "`querycurrentstate` = " + Properties.Resources.queryStageMailed + " " +
                                               "WHERE " +
                                               "queryid = " + DataGrdVuAdminQueries.SelectedRows[0].Cells["QueryId"].Value.ToString();
                    mySqlCommand.Prepare();

                    try
                    {
                        mySqlCommand.ExecuteNonQuery();
                        mySqlTransaction.Commit();
                    }
                    catch (Exception errquery)
                    {
                        MessageBox.Show("Error while executing insert query because:\n" + errquery.Message);
                    }

                    try
                    {
                        frmMysqlConnection.Close();
                    }
                    catch (Exception errConnClose)
                    {
                        MessageBox.Show("Error in Closing mysql connection because : " + errConnClose.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please load Queries First", "Load Queries", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }