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);
        }
Ejemplo n.º 4
0
        private void addButton_Click(object sender, EventArgs e)
        {
            bool error = false;

            if (string.IsNullOrWhiteSpace(reasonComboBox.Text))
            {
                reasonHintLabel.ForeColor = Color.Red;
                error = true;
            }
            else
            {
                reasonHintLabel.ForeColor = SystemColors.ControlText;
            }

            if (photoBox.Image == null)
            {
                photoHintLabel.ForeColor = Color.Red;
                error = true;
            }
            else
            {
                photoHintLabel.ForeColor = SystemColors.ControlText;
            }

            if (!error)
            {
                if (MessageBox.Show((!naReturnDateCheckBox.Checked) ? rs.GetString("askAddReportDialogbox") : rs.GetString("askAddReportExceptReturnDateDialogbox"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ProblemReport pr = new ProblemReport();
                    pr.setOrderID(orderDetail.getOrderID());

                    pr.setReportDate(DateTime.Now);
                    showReportDateLabel.Enabled = false;

                    pr.setReason(reasonComboBox.SelectedValue.ToString());
                    reasonComboBox.Enabled  = false;
                    reasonHintLabel.Enabled = false;

                    pr.setPhoto(photoBox.Image);
                    photoBox.Enabled          = false;
                    browsePhotoButton.Enabled = false;
                    photoHintLabel.Enabled    = false;

                    if (!naReturnDateCheckBox.Checked)
                    {
                        pr.setReturnDate(returnDateTime.Value);
                        naReturnDateCheckBox.Checked   = false;
                        naReturnDateCheckBox.Enabled   = false;
                        returnDateTime.Enabled         = false;
                        recordReturnDateButton.Enabled = false;
                    }

                    addButton.Enabled = false;
                    int i = prda.insert(pr, conn);

                    MessageBox.Show(rs.GetString("addNewReportSuccessMsg"));

                    reportDataGridView.Rows.Add(pr.getProblemID(), pr.getReportDate().ToLongDateString() + ", " + pr.getReportDate().ToLongTimeString());

                    reportDataGridView.ClearSelection();
                    foreach (DataGridViewRow row in reportDataGridView.Rows)
                    {
                        if ((pr.getProblemID().ToString()).Equals(row.Cells["problemIdColumn"].Value.ToString()))
                        {
                            row.Selected = true;
                            reportDataGridView.FirstDisplayedScrollingRowIndex = row.Index;
                        }
                    }
                }
            }
        }