コード例 #1
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            exportForm popup = new exportForm();

            popup.StartPosition = FormStartPosition.CenterParent;
            DialogResult dialogResult = popup.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                switch (popup.ExportType)
                {
                case "HOLE":
                    exportByHoleId();
                    break;

                case "SOURCE":
                    exportBySource(popup.Source);
                    break;

                case "TARGET":
                    exportByTarget(popup.Target, popup.Source);
                    break;

                default:
                    break;
                }
                return;
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            //exportIntercept(cbxSource.Text);
            var      culturaCol  = CultureInfo.GetCultureInfo("es-CO");
            DateTime dateReporte = Convert.ToDateTime(DateTime.Now, culturaCol);

            LoadLog.Register(dateReporte, clsRf.sUser, IpLocal, IpPublica, SerialHDD, Environment.MachineName, "Generate Report", "Report");
            Clear();
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dtgValueCalculate.RowCount > 1)
            {
                string contextValue = string.Empty;
                try
                {
                    foreach (DataGridViewRow row in dtgDetailHoleID.Rows)
                    {
                        if (row.Cells[0].Value != null && Convert.ToBoolean(row.Cells[0].Value) && !String.IsNullOrEmpty(row.Cells[0].Value.ToString()))
                        {
                            if (row.Cells[1].Value == null)
                            {
                                MessageBox.Show("Select all value Column Vn_mod this select");
                                return;
                            }
                        }
                    }
                    var      culturaCol  = CultureInfo.GetCultureInfo("es-CO");
                    DateTime dateReporte = Convert.ToDateTime(DateTime.Now, culturaCol);

                    foreach (DataGridViewRow row in dtgDetailHoleID.Rows)
                    {
                        if (row.Cells[0].Value != null && Convert.ToBoolean(row.Cells[0].Value) && !String.IsNullOrEmpty(row.Cells[0].Value.ToString()))
                        {
                            contextValue = "UPDATE [dbo].[DH_Samples]   SET      Vn_mod = '" + row.Cells[1].Value.ToString() + "' WHERE SKDHSamples =" + Convert.ToInt32(row.Cells[dtgDetailHoleID.Columns["SKDHSamples"].Index].Value) + " and HoleID ='" + row.Cells[dtgDetailHoleID.Columns["dhid"].Index].Value.ToString() + "'";
                            LoadLog.alterdataBase(contextValue);

                            LoadLog.Register(dateReporte, clsRf.sUser, IpLocal, IpPublica, SerialHDD, Environment.MachineName, contextValue, "update");
                        }
                        else
                        {
                            if (row.Cells[dtgDetailHoleID.Columns["Vn_mod_codes"].Index].Value != null && !String.IsNullOrEmpty(row.Cells[dtgDetailHoleID.Columns["Vn_mod_codes"].Index].Value.ToString()))
                            {
                                contextValue = "UPDATE [dbo].[DH_Samples]   SET      Vn_mod = Null WHERE SKDHSamples =" + Convert.ToInt32(row.Cells[dtgDetailHoleID.Columns["SKDHSamples"].Index].Value) + " and HoleID ='" + row.Cells[dtgDetailHoleID.Columns["dhid"].Index].Value.ToString() + "'";
                                LoadLog.alterdataBase(contextValue);
                                LoadLog.Register(dateReporte, clsRf.sUser, IpLocal, IpPublica, SerialHDD, Environment.MachineName, contextValue, "update");
                            }
                        }
                    }


                    foreach (DataGridViewRow row in dtgValueCalculate.Rows)
                    {
                        if (row.Cells[1].Value != null && !String.IsNullOrEmpty(row.Cells[1].Value.ToString()))
                        {
                            contextValue = String.Format("SELECT Count(1) FROM DH_IntercepInterval  WHERE HoleID = @HoleID and SKDHSamples= @SKDHSamples");
                            object count = LoadLog.Exist_DB(contextValue, row.Cells[1].Value.ToString(), Convert.ToDecimal(row.Cells[9].Value));
                            LoadLog.Register(dateReporte, clsRf.sUser, IpLocal, IpPublica, SerialHDD, Environment.MachineName, contextValue, "Search");

                            if (Convert.ToInt32(count) > 0)
                            {
                                string valueDescrioption = string.Empty;
                                if (!string.IsNullOrEmpty(txtComment.Text.Trim()))
                                {
                                    //valueDescrioption = string.Concat(txtComent.Text, " Con intervale inicial de ", Convert.ToDecimal(row.Cells[2].Value), " hasta ", valueTo);
                                    contextValue = "update dbo.DH_IntercepInterval set Tov=" + Convert.ToDecimal(row.Cells[3].Value) + ",Length_Grade=" + Convert.ToDecimal(row.Cells[4].Value) + ", Au_Grade=" + Convert.ToDecimal(row.Cells[5].Value) + ",Ag_Grade= " + Convert.ToDecimal(row.Cells[6].Value) + ",Comments='" + valueDescrioption + "',TotalRegister=" + Convert.ToInt32(row.Cells[7].Value) + " , Date_Event ='" + dateReporte.ToString() + "' where HoleID ='" + row.Cells[1].Value.ToString() + "' AND SKDHSamples =" + Convert.ToDecimal(row.Cells[9].Value);
                                    LoadLog.alterdataBase(contextValue);
                                    LoadLog.Register(dateReporte, clsRf.sUser, IpLocal, IpPublica, SerialHDD, Environment.MachineName, contextValue, "Update");
                                }
                                else
                                {
                                    MessageBox.Show("Comment is required for the rank update");
                                    return;
                                }
                            }
                            else
                            {
                                contextValue = "INSERT INTO dbo.DH_IntercepInterval(HoleID,Fromv,Tov,Length_Grade,Au_Grade,Ag_Grade,Comments,TotalRegister,Vn_mod,SKDHSamples,Date_Event)VALUES(" + "'" + row.Cells[1].Value.ToString() + "'," + Convert.ToDecimal(row.Cells[2].Value) + " ," + Convert.ToDecimal(row.Cells[3].Value) + "," + Convert.ToDecimal(row.Cells[4].Value) + " ," + Convert.ToDecimal(row.Cells[5].Value) + "," + Convert.ToDecimal(row.Cells[6].Value) + ",'" + txtComment.Text + "'," + Convert.ToInt32(row.Cells[7].Value) + ",'" + row.Cells[8].Value.ToString() + "'," + row.Cells[9].Value.ToString() + ",'" + dateReporte + "')";
                                LoadLog.alterdataBase(contextValue);
                                LoadLog.Register(dateReporte, clsRf.sUser, IpLocal, IpPublica, SerialHDD, Environment.MachineName, contextValue, "Update");
                            }
                        }
                    }

                    MessageBox.Show("The Calculated items were save successful.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtComment.Text       = String.Empty;
                    lblSavedItems.Visible = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("There is not data to save.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }