コード例 #1
0
 private void frmPlanGen_FormClosed(object sender, FormClosedEventArgs e)
 {
     Dgv1.Update();
     Dgv1.EndEdit();
     Dgv1.DataSource = null;
     Dgv1            = null;
     //
 }
コード例 #2
0
 private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 9)
     {
         Dgv1.BeginEdit(true);
     }
     else
     {
         Dgv1.EndEdit();
     }
 }
コード例 #3
0
 private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (Dgv1.Columns[e.ColumnIndex].DefaultCellStyle.ForeColor == Color.Blue)
     {
         Dgv1.BeginEdit(true);
     }
     else
     {
         Dgv1.EndEdit();
     }
 }
コード例 #4
0
        public void spisok()
        {
            if (my.IsNumeric(idComplex.SelectedValue))
            {
                Dgv1.EndEdit();
                DataSet ds = new DataSet(); ds.Clear();
                ds = my.GetDS("set language русский; exec sSelPlanGen  " + idComplex.SelectedValue.ToString() + " , '" + my.Uper + "'", my.sconn);

                Dgv1.DataSource = ds.Tables[0];
                my.naimDG("Кодировка, Расшифровка,Год баз.,Год тек.,Кв баз.,Кв тек.,Месяц баз.,Месяц тек.", Dgv1, "");
            }
        }
コード例 #5
0
 private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (WithOpen)
     {
         return;
     }
     if ((e.ColumnIndex >= 13 || Dgv1.Columns[e.ColumnIndex].Name == "idisp") && Dgv1.Rows[e.RowIndex].DefaultCellStyle.BackColor != Color.LightCyan)
     {
         Dgv1.BeginEdit(true);
     }
     else
     {
         Dgv1.EndEdit();
     }
 }
コード例 #6
0
ファイル: frmSSRSm.cs プロジェクト: jane-safr/SMRC
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                String sel;

                Cursor = Cursors.WaitCursor;
                ds     = new DataSet();
                ds.Clear();
                sel = my.FilterSel(123, this, my.sconn, " and idcomplexchapter in (select idcomplexchapter from Sprav.dbo.tComplexChapter  where idcomplex = " + idComplex.SelectedValue.ToString() + ((int)idChapter.SelectedValue != 0 ? " and idchapter = " + idChapter.SelectedValue.ToString() : "") + ")");

                da = new SqlDataAdapter();
                DaDs dads1 = new DaDs();
                dads1.DaInd(0, sel, my.sconn, "", ds, true);
                ds.Tables[0].Columns.Add("SumSt", typeof(Double));
                da = dads1.Da[0];
                da.UpdateCommand.CommandText = "UPDATE [sprav].[dbo].[tsosr] SET [ordernom] = @p1, [osr] = @p2, [nmosr] = @p3, [str] = @p4, [mont] = @p5, [obor] = @p6, [proch] = @p7 WHERE [idosr] = @p8";
                da.InsertCommand.CommandText = "INSERT INTO [sprav].[dbo].[tsosr] ([ordernom], [osr], [nmosr], [str], [mont], [obor], [proch],[idcomplexchapter]) VALUES (@p1, @p2, @p3, @p4, @p5, @p6, @p7," + idcomplexchapter().ToString() + "); select   idosr,  ordernom, osr, nmosr, str, mont, obor, proch from         sprav.dbo.tsosr where idosr= SCOPE_IDENTITY()";
                DataView dv = new DataView();
                dv.Table = ds.Tables[0];
                //dv.Sort =
                Dgv1.DataSource = null;
                Dgv1.Columns.Clear();
                Dgv1.DataSource = dv;
                foreach (DataGridViewColumn col in Dgv1.Columns)
                {
                    if (col.ValueType.Name == "Double")
                    {
                        col.DefaultCellStyle.Format    = "# ###";
                        col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
                    }
                }

                DataGridViewButtonColumn but = new DataGridViewButtonColumn();
                but.Name = "but";
                DataGridViewCellStyle cellStyle = new DataGridViewCellStyle();
                cellStyle.BackColor = System.Drawing.SystemColors.Control;
                //cellStyle.Format = "# ##0";
                but.DefaultCellStyle = cellStyle;

                Dgv1.Columns.Add(but);

                my.naimDG(my.headStr, Dgv1, my.widthStr);
                Double w = 0;
                for (int i = 0; i <= Dgv1.Columns.Count - 1; i++)
                {
                    w = w + Dgv1.Columns[i].Width;
                }
                Width         = (int)w + 50;
                Cursor        = Cursors.Default;
                tslCount.Text = "Всего: " + ((int)Dgv1.Rows.Count - 1).ToString();
                double Str = 0; double Mont = 0; double Obor = 0; double Proch = 0; double SumSt = 0;

                for (int i = 0; i < Dgv1.Rows.Count - 1; i++)
                {
                    Dgv1.Rows[i].Cells["SumSt"].Value = (double)Dgv1.Rows[i].Cells["Str"].Value + (double)Dgv1.Rows[i].Cells["Mont"].Value + (double)Dgv1.Rows[i].Cells["Obor"].Value + (double)Dgv1.Rows[i].Cells["Proch"].Value;
                    Str   = Str + (double)Dgv1.Rows[i].Cells["Str"].Value;
                    Mont  = Mont + (double)Dgv1.Rows[i].Cells["Mont"].Value;
                    Obor  = Obor + (double)Dgv1.Rows[i].Cells["Obor"].Value;
                    Proch = Proch + (double)Dgv1.Rows[i].Cells["Proch"].Value;
                    SumSt = SumSt + (double)(Dgv1.Rows[i].Cells["SumSt"].Value == null ? 0.0 : Dgv1.Rows[i].Cells["SumSt"].Value);
                    Dgv1.EndEdit();
                }
                //my.Up(da, ds.Tables[0]);
                tStr.Text   = Str.ToString();
                tMont.Text  = Mont.ToString();
                tObor.Text  = Obor.ToString();
                tProch.Text = Proch.ToString();
                tSumSt.Text = SumSt.ToString();
                Dgv1.Sort(Dgv1.Columns["OrderNom"], ListSortDirection.Ascending);
                my.cn.Open();
                my.sc.CommandText = my.FilterSel(125, this, my.sconn, " and idcomplexchapter in (select idcomplexchapter from Sprav.dbo.tComplexChapter  where idcomplex = " + idComplex.SelectedValue.ToString() + ((int)idChapter.SelectedValue != 0 ? " and idchapter = " + idChapter.SelectedValue.ToString() : "") + ")");
                SqlDataReader sd = my.sc.ExecuteReader();
                while (sd.Read())
                {
                    tStr91.Text   = sd["Str91"].ToString();
                    tMont91.Text  = sd["Mont91"].ToString();
                    tObor91.Text  = sd["Obor91"].ToString();
                    tProch91.Text = sd["Proch91"].ToString();
                    tSumSt91.Text = sd["SumSt91"].ToString();
                    //tStr91 = (double)sd["Str91"];
                    //tStr91 = (double)sd["Str91"];
                    //tStr91 = (double)sd["Str91"];
                }
                sd.Close();
                my.sc.CommandText = my.FilterSel(126, this, my.sconn, " and idcomplexchapter in (select idcomplexchapter from Sprav.dbo.tComplexChapter  where idcomplex = " + idComplex.SelectedValue.ToString() + ((int)idChapter.SelectedValue != 0 ? " and idchapter = " + idChapter.SelectedValue.ToString() : "") + ")");
                sd = my.sc.ExecuteReader();
                while (sd.Read())
                {
                    tVSr91.Text = sd["VSr91"].ToString();
                    tVMr91.Text = sd["VMr91"].ToString();
                    tVPr91.Text = sd["VPr91"].ToString();
                    tVOb91.Text = sd["VOb91"].ToString();
                    tV91.Text   = sd["V91"].ToString();
                    tOstSr.Text = Convert.ToString(Convert.ToDouble(tStr91.Text) - (int)sd["VSr91"]);
                    tOstMr.Text = Convert.ToString(Convert.ToDouble(tMont91.Text) - (int)sd["VMr91"]);
                    tOstPr.Text = Convert.ToString(Convert.ToDouble(tProch91.Text) - (int)sd["VPr91"]);
                    tOstOb.Text = Convert.ToString(Convert.ToDouble(tObor91.Text) - (int)sd["VOb91"]);
                    tOst.Text   = Convert.ToString(Convert.ToDouble(tSumSt91.Text) - (int)sd["V91"]);


                    //tOstMr.Text = sd["VMr91"].ToString();
                    //tOstPr.Text = sd["VPr91"].ToString();
                    //tOstOb.Text = sd["V91"].ToString();
                    //tOst.Text = sd["V91"].ToString();
                }
                sd.Close();
                my.cn.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                if ((int)my.cn.State == 1)
                {
                    my.cn.Close();
                }
                //throw;
            }
        }
コード例 #7
0
        public void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (!my.IsNumeric(idOSR.SelectedValue))
                {
                    return;
                }
                String sel;

                Cursor = Cursors.WaitCursor;
                ds     = new DataSet();
                ds.Clear();
                sel = my.FilterSel(124, this, my.sconn, " and idosr =  " + idOSR.SelectedValue.ToString() + ((int)idChapter.SelectedValue != 0 ? " and idobj = " + idChapter.SelectedValue.ToString() : ""));

                da = new SqlDataAdapter();
                DaDs dads1 = new DaDs();
                dads1.DaInd(0, sel, my.sconn, "", ds, true);
                ds.Tables[0].Columns.Add("SumSt", typeof(Double));
                da = dads1.Da[0];
                da.UpdateCommand.CommandText = "";//"UPDATE [sprav].[dbo].[tsmeti] SET  [ndoc] = @p2, [nomer] = @p3, [nmsmeti] = @p4, [sum91or] = @p5, [summr91] = @p6, [stobor91] = @p7, [sumprochz91] = @p8 WHERE [idsm] = @p9";
                da.InsertCommand.CommandText = "";
                da.DeleteCommand.CommandText = "";
                DataView dv = new DataView();
                dv.Table        = ds.Tables[0];
                Dgv1.DataSource = null;
                Dgv1.Columns.Clear();
                Dgv1.DataSource = dv;
                foreach (DataGridViewColumn col in Dgv1.Columns)
                {
                    if (col.ValueType.Name == "Double")
                    {
                        col.DefaultCellStyle.Format    = "# ###";
                        col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
                    }
                }
                Dgv1.VLadd("IsSSR", "Входят в ССР", "SELECT     idIsSSR, NMIsSSR FROM  sprav.dbo.tsIsSSR", my.sconn, SMRC.DGVt.TypeVL.ComboBoxDropDown, 6);
                DataGridViewButtonColumn but = new DataGridViewButtonColumn();
                but.Name = "but";
                DataGridViewCellStyle cellStyle = new DataGridViewCellStyle();
                cellStyle.BackColor = System.Drawing.SystemColors.Control;

                but.DefaultCellStyle = cellStyle;

                Dgv1.Columns.Add(but);

                my.naimDG(my.headStr, Dgv1, my.widthStr);
                Double w = 0;
                for (int i = 0; i <= Dgv1.Columns.Count - 1; i++)
                {
                    w = w + Dgv1.Columns[i].Width;
                }
                Width         = (int)w + 50;
                Cursor        = Cursors.Default;
                tslCount.Text = "Всего: " + ((int)Dgv1.Rows.Count - 1).ToString();
                double Str = 0; double Mont = 0; double Obor = 0; double Proch = 0; double SumSt = 0;

                for (int i = 0; i < Dgv1.Rows.Count - 1; i++)
                {
                    Dgv1.Rows[i].Cells["SumSt"].Value = (double)Dgv1.Rows[i].Cells["Sum91Or"].Value + (double)Dgv1.Rows[i].Cells["StObor91"].Value + (double)Dgv1.Rows[i].Cells["SumProchZ91"].Value;
                    Str   = Str + (double)Dgv1.Rows[i].Cells["Sum91Or"].Value - (double)Dgv1.Rows[i].Cells["SumMR91"].Value;
                    Mont  = Mont + (double)Dgv1.Rows[i].Cells["SumMR91"].Value;
                    Obor  = Obor + (double)Dgv1.Rows[i].Cells["StObor91"].Value;
                    Proch = Proch + (double)Dgv1.Rows[i].Cells["SumProchZ91"].Value;
                    SumSt = SumSt + (double)(Dgv1.Rows[i].Cells["SumSt"].Value == null ? 0.0 : Dgv1.Rows[i].Cells["SumSt"].Value);
                    Dgv1.EndEdit();
                }
                //my.Up(da, ds.Tables[0]);
                tStr91.Text   = Str.ToString();
                tMont91.Text  = Mont.ToString();
                tObor91.Text  = Obor.ToString();
                tProch91.Text = Proch.ToString();
                tSumSt91.Text = SumSt.ToString();
                my.cn.Open();
                my.sc.CommandText = my.FilterSel(127, this, my.sconn, " and idosr  = " + idOSR.SelectedValue.ToString());
                SqlDataReader sd = my.sc.ExecuteReader();
                while (sd.Read())
                {
                    tStr.Text   = sd["Str"].ToString();
                    tMont.Text  = sd["Mont"].ToString();
                    tObor.Text  = sd["Obor"].ToString();
                    tProch.Text = sd["Proch"].ToString();
                    tSumSt.Text = sd["SumSt"].ToString();
                }
                sd.Close();
                my.sc.CommandText = my.FilterSel(126, this, my.sconn, " and sprav.dbo.tsmeti.idosr  = " + idOSR.SelectedValue.ToString());
                sd = my.sc.ExecuteReader();
                while (sd.Read())
                {
                    tVSr91.Text = sd["VSr91"].ToString();
                    tVMr91.Text = sd["VMr91"].ToString();
                    tVPr91.Text = sd["VPr91"].ToString();
                    tVOb91.Text = sd["VOb91"].ToString();
                    tV91.Text   = sd["V91"].ToString();
                    tOstSr.Text = Convert.ToString(Convert.ToDouble(tStr91.Text) - (int)sd["VSr91"]);
                    tOstMr.Text = Convert.ToString(Convert.ToDouble(tMont91.Text) - (int)sd["VMr91"]);
                    tOstPr.Text = Convert.ToString(Convert.ToDouble(tProch91.Text) - (int)sd["VPr91"]);
                    tOstOb.Text = Convert.ToString(Convert.ToDouble(tObor91.Text) - (int)sd["VOb91"]);
                    tOst.Text   = Convert.ToString(Convert.ToDouble(tSumSt91.Text) - (int)sd["V91"]);
                }
                sd.Close();
                my.cn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                if ((int)my.cn.State == 1)
                {
                    my.cn.Close();
                }
                //throw;
            }
        }