示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (dtpStartDate.Value > dtpEndDate.Value)
            {
                MessageBox.Show("Invalid start date and end date range.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            pnlTestSched.Visible = false;
            SqlConnection sqlcnn = GISClass.DBConnection.GISConnection();
            SqlCommand    sqlcmd = new SqlCommand();

            //FinalReport Master Record
            txtReportNo.Text = GISClass.General.NewID("FinalRptMaster", "ReportNo").ToString();

            sqlcmd.Connection = sqlcnn;

            sqlcmd.Parameters.AddWithValue("@nMode", 1);
            sqlcmd.Parameters.AddWithValue("@RptNo", Convert.ToInt32(txtReportNo.Text));
            sqlcmd.Parameters.AddWithValue("@RptNotes", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@IntNotes", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@Method", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@Conclusion", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@Purpose", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@Results", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@Memo", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@SpID", nSponsorID);
            sqlcmd.Parameters.AddWithValue("@ConID", nContactID);
            sqlcmd.Parameters.AddWithValue("@UserID", LogIn.nUserID);
            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.CommandText = "spAddEditFinRptMstr";
            try
            {
                sqlcmd.ExecuteNonQuery();
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                if (ex.Message.ToString().IndexOf("PRIMARY KEY") >= 0)
                {
                    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            sqlcmd.Dispose();
            sqlcmd            = new SqlCommand();
            sqlcmd.Connection = sqlcnn;
            //Final Report Revision
            sqlcmd.Parameters.AddWithValue("@nMode", 1);
            sqlcmd.Parameters.AddWithValue("@RptNo", Convert.ToInt32(txtReportNo.Text));
            sqlcmd.Parameters.AddWithValue("@RevNo", 0);
            sqlcmd.Parameters.AddWithValue("@RevDate", DateTime.Now);
            sqlcmd.Parameters.AddWithValue("@StudyDirID", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@ReasonCode", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@Reason", DBNull.Value);
            sqlcmd.Parameters.AddWithValue("@UserID", LogIn.nUserID);
            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.CommandText = "spAddEditfinRptRev";
            try
            {
                sqlcmd.ExecuteNonQuery();
            }
            catch
            {
            }
            sqlcmd.Dispose();
            //Final Report GBLs
            for (int i = 0; i < dgvTestResults.Rows.Count; i++)
            {
                sqlcmd            = new SqlCommand();
                sqlcmd.Connection = sqlcnn;

                sqlcmd.Parameters.AddWithValue("@nMode", 1);
                sqlcmd.Parameters.AddWithValue("@RptNo", Convert.ToInt32(txtReportNo.Text));
                sqlcmd.Parameters.AddWithValue("@RevNo", 0);
                sqlcmd.Parameters.AddWithValue("@LogNo", nLogNo);
                sqlcmd.Parameters.AddWithValue("@SC", Convert.ToInt16(dgvTestResults.Rows[i].Cells["ServiceCode"].Value));
                sqlcmd.Parameters.AddWithValue("@FormatNo", 1);
                sqlcmd.Parameters.AddWithValue("@DteOn", dtpStartDate.Value);
                sqlcmd.Parameters.AddWithValue("@DteOff", dtpEndDate.Value);
                sqlcmd.Parameters.AddWithValue("@UserID", LogIn.nUserID);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.CommandText = "spAddEditFinRptLogs";
                try
                {
                    sqlcmd.ExecuteNonQuery();
                }
                catch
                {
                }
                sqlcmd.Dispose();
                //Update Log Test's ReportNo field
                sqlcmd            = new SqlCommand();
                sqlcmd.Connection = sqlcnn;
                sqlcmd.Parameters.AddWithValue("@RptNo", Convert.ToInt32(txtReportNo.Text));
                sqlcmd.Parameters.AddWithValue("@RevNo", 0);
                sqlcmd.Parameters.AddWithValue("@LogNo", nLogNo);
                sqlcmd.Parameters.AddWithValue("@SC", Convert.ToInt16(dgvTestResults.Rows[i].Cells["ServiceCode"].Value));
                sqlcmd.Parameters.AddWithValue("@FormatNo", 1);
                sqlcmd.Parameters.AddWithValue("@UserID", LogIn.nUserID);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.CommandText = "spUpdLogTestRptNo";
                try
                {
                    sqlcmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                sqlcmd.Dispose();
            }
            sqlcmd.Dispose(); sqlcnn.Close(); sqlcnn.Dispose();

            if (File.Exists(@"\\GBLNJ4\GIS\Reports\IngredionRpt.rpt") == false)
            {
                MessageBox.Show("Report file is under construction." + Environment.NewLine + "Please contact the IT Department for updates.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            LabRpt rpt = new LabRpt();

            rpt.rptName     = "FinalRptIngredion";
            rpt.rptFile     = "IngredionRpt.rpt";
            rpt.WindowState = FormWindowState.Maximized;
            rpt.nLogNo      = Convert.ToInt32(txtGBLNo.Text);
            rpt.nRptNo      = Convert.ToInt32(txtReportNo.Text);
            rpt.SpID        = nSponsorID;
            rpt.nRevNo      = 0;
            try
            {
                rpt.Show();
            }
            catch { }
            SendMail();
        }
示例#2
0
        private void btnEMail_Click(object sender, EventArgs e)
        {
            if (txtDateEMailed.Text == "")
            {
                SqlConnection sqlcnn = GISClass.DBConnection.GISConnection();
                SqlCommand    sqlcmd = new SqlCommand();

                //Save Data
                //bsMain.EndEdit();
                DataTable dt = new DataTable();
                dt = dtTestData.GetChanges();
                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sqlcmd            = new SqlCommand();
                        sqlcmd.Connection = sqlcnn;

                        if (dtTestData.Rows[i].RowState.ToString() == "Added")
                        {
                            sqlcmd.Parameters.AddWithValue("@nMode", 1);
                        }
                        else
                        {
                            sqlcmd.Parameters.AddWithValue("@nMode", 2);
                        }
                        sqlcmd.Parameters.AddWithValue("@LogNo", nLogNo);
                        sqlcmd.Parameters.AddWithValue("@SC", dt.Rows[i]["ServiceCode"].ToString());
                        sqlcmd.Parameters.AddWithValue("@DateTested", dt.Rows[i]["DateTested"]);
                        sqlcmd.Parameters.AddWithValue("@TestResult", dt.Rows[i]["TestResult"]);
                        sqlcmd.Parameters.AddWithValue("@Note", dt.Rows[i]["Note"]);
                        sqlcmd.Parameters.AddWithValue("@AnalystID", dt.Rows[i]["AnalystID"]);
                        sqlcmd.Parameters.AddWithValue("@UserID", LogIn.nUserID);

                        sqlcmd.CommandType = CommandType.StoredProcedure;
                        sqlcmd.CommandText = "spAddEditIngredionData";
                        try
                        {
                            sqlcmd.ExecuteNonQuery();
                        }
                        catch
                        {
                        }
                        sqlcmd.Dispose();
                    }
                }
                sqlcmd.Dispose(); sqlcnn.Dispose();
            }
            DialogResult dReply = new DialogResult();

            dReply = MessageBox.Show("Do you want to send this to the Sponsor?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dReply == DialogResult.No)
            {
                return;
            }
            if (txtReportNo.Text == "" || txtReportNo.Text == "0" || txtDateEMailed.Text == "") // Revised 5/4/2016
            {
                //Create a New Report
                if (nRptNo == 0)
                {
                    DialogResult dAns = new DialogResult();
                    dAns = MessageBox.Show("A new report would be created." + Environment.NewLine + "Do you want to proceed?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dAns == DialogResult.No)
                    {
                        return;
                    }
                    pnlTestSched.Visible = true;
                    return;
                }
                if (File.Exists(@"\\GBLNJ4\GIS\Reports\IngredionRpt.rpt") == false)
                {
                    MessageBox.Show("Report file is under construction." + Environment.NewLine + "Please contact the IT Department for updates.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                LabRpt rpt = new LabRpt();
                rpt.rptName     = "FinalRptIngredion";
                rpt.rptFile     = "IngredionRpt.rpt";
                rpt.WindowState = FormWindowState.Maximized;
                rpt.nLogNo      = Convert.ToInt32(txtGBLNo.Text);
                rpt.nRptNo      = Convert.ToInt32(txtReportNo.Text);
                rpt.SpID        = nSponsorID;
                rpt.nRevNo      = 0;
                try
                {
                    rpt.Show();
                }
                catch { }
                rpt.WindowState = FormWindowState.Minimized;
            }
            SendMail();
        }