Ejemplo n.º 1
0
        private void reportDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                ProblemReport pr = prda.getOneReportByID((int)reportDataGridView.Rows[e.RowIndex].Cells["problemIdColumn"].Value, conn);
                showReportDateLabel.Text     = pr.getReportDate().ToLongDateString();
                reasonComboBox.SelectedValue = pr.getReason();
                photoBox.Image = pr.getPhoto();

                showReportDateLabel.Enabled = false;
                reasonComboBox.Enabled      = false;
                reasonHintLabel.Enabled     = false;
                photoBox.Enabled            = false;
                browsePhotoButton.Enabled   = false;
                zoomPhotoButton.Enabled     = true;
                photoHintLabel.Enabled      = false;
                if (pr.getReturnDate() == null)
                {
                    naReturnDateCheckBox.Checked = true;
                    naReturnDateCheckBox.Enabled = true;
                    returnDateTime.Enabled       = false;
                }
                else
                {
                    naReturnDateCheckBox.Checked = false;
                    naReturnDateCheckBox.Enabled = false;
                    returnDateTime.Enabled       = false;
                }

                addButton.Enabled = false;
                recordReturnDateButton.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        public int update(ProblemReport problemReport, MySqlConnection conn)
        {
            conn.Open();
            MySqlCommand cmd = new MySqlCommand("UPDATE `problem_report` SET `Photo`=@photo,`Reason`=@reason,`Order_ID`=@orderID,`Report_date`=@reportDate,`Return_date`=@returnDate WHERE `Problem_ID`=@problemID", conn);

            cmd.Parameters.AddWithValue("@problemID", problemReport.getProblemID());
            cmd.Parameters.AddWithValue("@photo", ImageConverter.imageToByteArray(problemReport.getPhoto()));
            cmd.Parameters.AddWithValue("@reason", problemReport.getReason());
            cmd.Parameters.AddWithValue("@orderID", problemReport.getOrderID());
            cmd.Parameters.AddWithValue("@reportDate", problemReport.getReportDate().ToString("yyyy-MM-dd HH:mm:ss"));
            cmd.Parameters.AddWithValue("@returnDate", (problemReport.getReturnDate() != null) ? problemReport.getReturnDate().Value.ToString("yyyy-MM-dd HH:mm:ss") : null);
            cmd.Prepare();
            int i = cmd.ExecuteNonQuery();

            conn.Close();
            return(i);
        }
Ejemplo n.º 3
0
        public int insert(ProblemReport problemReport, MySqlConnection conn)
        {
            conn.Open();
            MySqlCommand cmd = new MySqlCommand("INSERT INTO `problem_report`(`Photo`, `Reason`, `Order_ID`, `Report_date`, `Return_date`) " +
                                                "VALUES(@photo, @reason, @orderID, @reportDate, @returnDate)", conn);

            cmd.Parameters.AddWithValue("@photo", ImageConverter.imageToByteArray(problemReport.getPhoto()));
            cmd.Parameters.AddWithValue("@reason", problemReport.getReason());
            cmd.Parameters.AddWithValue("@orderID", problemReport.getOrderID());
            cmd.Parameters.AddWithValue("@reportDate", problemReport.getReportDate().ToString("yyyy-MM-dd HH:mm:ss"));
            cmd.Parameters.AddWithValue("@returnDate", (problemReport.getReturnDate() != null) ? problemReport.getReturnDate().Value.ToString("yyyy-MM-dd HH:mm:ss") : null);
            cmd.Prepare();
            int i = cmd.ExecuteNonQuery();

            problemReport.setProblemID((int.Parse(cmd.LastInsertedId.ToString())));
            conn.Close();
            return(i);
        }