private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e) { //e.ColumnIndex if (Dgv1.Columns[e.ColumnIndex].DefaultCellStyle.ForeColor == Color.Blue) { Dgv1.BeginEdit(true); } }
private void frmPlanGen_FormClosed(object sender, FormClosedEventArgs e) { Dgv1.Update(); Dgv1.EndEdit(); Dgv1.DataSource = null; Dgv1 = null; // }
public void spisok() { if (WithLoad || idStrucZag.SelectedValue == null) { return; } if (idPredpr.SelectedValue == null) { MessageBox.Show("Выберите предприятие!"); return; } String sel; Cursor = Cursors.WaitCursor; my.sc.CommandText = my.FilterSel(217, this, my.sconn, " and idpredpr = " + idPredpr.SelectedValue.ToString() + " and idStrucZag = " + idStrucZag.SelectedValue.ToString()); my.cn.Open(); SqlDataReader DRd = my.sc.ExecuteReader(); DRd.Read(); tYear.Text = DRd["year"].ToString(); Podtv.Checked = (bool)DRd["Podtv"]; if ((int)DRd["idUsPodtv"] != 0) { FIO.Text = (string)DRd["FIO"]; } DRd.Close(); //if (Podtv.Checked) //{ Dgv1.EditMode = DataGridViewEditMode.EditProgrammatically; } //else //{ Dgv1.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; } ds = new DataSet(); ds.Clear(); sel = my.FilterSel(216, this, my.sconn, " and idpredpr = " + idPredpr.SelectedValue.ToString() + " and year = " + tYear.Text + " and idStrucZag = " + idStrucZag.SelectedValue.ToString()); //my.cn.Open(); da = new SqlDataAdapter(sel, my.cn); da.Fill(ds); my.cn.Close(); DataView dv = new DataView(); dv.Table = ds.Tables[0]; WithUp = false; Dgv1.DataSource = null; Dgv1.Columns.Clear(); Dgv1.DataSource = dv; Dgv1.VLadd("idPO", "ПО", "SELECT IdEntpr, shNMEntpr FROM Sprav.dbo.tsEntpr WHERE (Sprav.dbo.isb(Bits, 3) = 1) ORDER BY shNMEntpr", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 5); Dgv1.VLadd("idStrucNM", "ПО", "SELECT TOP (100) PERCENT dbo.tStrucNM.idStrucNM, 'ГП ' + Sprav.dbo.tsEntpr.shNMEntpr + ' ' + dbo.tStrucNM.NMStruc AS NMStruc FROM dbo.tStrucNM INNER JOIN Sprav.dbo.tsEntpr ON dbo.tStrucNM.idgp = Sprav.dbo.tsEntpr.IdEntpr", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 4); foreach (DataGridViewColumn col in Dgv1.Columns) { if (col.ValueType.Name == "Integer") { col.DefaultCellStyle.Format = "# ###"; col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight; } } my.naimDG(my.headStr, Dgv1, my.widthStr); Cursor = Cursors.Default; WithUp = true; }
private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e) { //Dgv1.BeginEdit(true); //if (!Withup) { return; } if (WithUp & !Podtv.Checked) { Dgv1.BeginEdit(true); } }
private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e) { Dgv1.BeginEdit(true); if (e.ColumnIndex == 0) { oldkodir = Dgv1.Rows[e.RowIndex].Cells["kodir"].Value.ToString(); } Ras(e); }
private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e) { if (!Withup) { return; } if (Dgv1.EditMode != DataGridViewEditMode.EditProgrammatically) { Dgv1.BeginEdit(true); } }
private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 9) { Dgv1.BeginEdit(true); } else { Dgv1.EndEdit(); } }
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, ""); } }
private void toolStripButton3_Click(object sender, EventArgs e) { if (WithUp) { Dgv1.Rows.RemoveAt(Dgv1.CurrentRow.Index); Dgv1.Refresh(); } else { MessageBox.Show("У Вас нет прав для выполнения этой операции!"); } // ds.Tables[0].Rows.RemoveAt(Dgv1.CurrentRow.Index); }
private void ObnPlanSmeti() { SqlDataAdapter da; string s = ""; s = my.FilterSel(14, this, my.sconn, ""); string h = my.headStr; string w = my.widthStr; ds = new DataSet(); da = new SqlDataAdapter(s, my.sconn); ds.Clear(); Dgv1.DataSource = null; if (rbplan.Checked) { s = s + " and idplan = " + idplan.ToString(); da.SelectCommand.CommandText = s; da.Fill(ds); } else { if (rbosr.Checked) { s = s + " and idOsr = " + IdOSR.SelectedValue.ToString() + " and Osnovnoi = 1 and VidPeriod = " + (rb1.Checked ? "2" : "1") + " and period = '" + Period.SelectedValue.ToString() + "' "; da.SelectCommand.CommandText = s; da.Fill(ds); da = new SqlDataAdapter("set language 'русский' exec sNezaversh '" + Period.SelectedValue.ToString() + "','" + (rb1.Checked ? ((DateTime)Period.SelectedValue).AddMonths(3).ToString() : Period.SelectedValue.ToString()) + "',0,3," + IdOSR.SelectedValue.ToString(), my.sconn); da.Fill(ds); } else { s = s + " and idOsr = " + IdOSR.SelectedValue.ToString() + " and 1 = 5 "; da.SelectCommand.CommandText = s; da.Fill(ds); da = new SqlDataAdapter("set language 'русский' exec sNezaversh '" + Period.SelectedValue.ToString() + "','" + (rb1.Checked ? ((DateTime)Period.SelectedValue).AddMonths(3).ToString() : Period.SelectedValue.ToString()) + "',0,3,0", my.sconn); da.Fill(ds); } } //exec sNezaversh '01.06.2009','01.06.2009',2,3,167 Dgv1.DataSource = ds.Tables[0]; Dgv1.VLadd("idisp", "Исполнитель", "SELECT IdPred, Name FROM v_IzPrivlIsp ORDER BY Name", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 5); for (int i = 13; i < Dgv1.Columns.Count; i++) { Dgv1.Columns[i].DefaultCellStyle.Format = "# ###.###"; Dgv1.Columns[i].DefaultCellStyle.ForeColor = Color.Blue; } my.naimDG(h, Dgv1, w); Dgv1.AllowUserToAddRows = false; Dgv1.EditMode = DataGridViewEditMode.EditProgrammatically; }
private void toolStripButton1_Click(object sender, EventArgs e) { if (WithUp) { TreeViewEventArgs tn = new TreeViewEventArgs(treeView1.SelectedNode); Dgv1.CommitEdit(DataGridViewDataErrorContexts.Commit); BindingContext[ds, "tab0"].EndCurrentEdit(); // da[0].AcceptChangesDuringFill = false; my.Up(da[0], ds.Tables[0]); treeView1_AfterSelect(Dgv1, tn); } else { MessageBox.Show("У Вас нет прав для выполнения этой операции!"); } }
private void Dgv1_CellEnter(object sender, DataGridViewCellEventArgs e) { if (WithOpen) { return; } if (Dgv1.Columns[e.ColumnIndex].DefaultCellStyle.ForeColor == Color.Blue) { Dgv1.BeginEdit(true); } else { Dgv1.EndEdit(); } }
private void gridviwbind() { string s = "select slno as SlNo,Standard,Type,MinMark as [Minimum Mark],MaxMark as [Maximum Mark],Grade from tbl_gradesetting"; SqlDataAdapter da = new SqlDataAdapter(s, d.con); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count >= 1) { Dgv1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; Dgv1.AutoResizeColumns(); Dgv1.DataSource = ds.Tables[0]; Dgv1.Columns[0].Visible = false; } }
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(); } }
private void tsbAdd_Click(object sender, EventArgs e) { if (nbut1 == 8) { my.sc.CommandText = "exec sNewSmeta 10,0,1," + my.Id_us.ToString() + ",1 "; my.cn.Open(); my.Szap = my.sc.ExecuteScalar().ToString(); my.cn.Close(); int idsm = Convert.ToInt32(my.Szap); if (!my.isFormInMdi("frmCapSm", idsm, my.MDIForm)) { frmCapSm fr = new frmCapSm(); fr.MdiParent = my.MDIForm; fr.idsm = idsm; fr.Tag = my.Szap; fr.Show(); } } //if (nbut1 == 704) //{ // DataRow dr = ds.Tables[0].Rows.Add(); // //my.sc.CommandText = "exec sNewSmeta 10,0,1," + my.Id_us.ToString() + ",1 "; // //my.cn.Open(); // //my.Szap = my.sc.ExecuteScalar().ToString(); // //my.cn.Close(); // //int idsm = Convert.ToInt32(my.Szap); // //if (!my.isFormInMdi("frmCapSm", idsm, my.MDIForm)) // //{ // // frmCapSm fr = new frmCapSm(); // // fr.MdiParent = my.MDIForm; // // fr.idsm = idsm; // // fr.Tag = my.Szap; // // fr.Show(); // //} //} //else { DataRow dr = ds.Tables[0].Rows.Add(); dr[1] = ' '; Dgv1.CurrentCell = Dgv1.Rows[Dgv1.Rows.Count - 1].Cells[1]; Dgv1.BeginEdit(true); } }
private void ObnPlan() { string s = ""; s = my.FilterSel(186, this, my.sconn, ""); string h = my.headStr; string w = my.widthStr; ds = new DataSet(); da = new SqlDataAdapter(s, my.sconn); ds.Clear(); Dgv1.DataSource = null; s = s + " and idkp = " + idplan.ToString(); da.SelectCommand.CommandText = s; da.Fill(ds); Dgv1.DataSource = ds.Tables[0]; Dgv1.VLadd("idisp", "Исполнитель", "SELECT IdPred, Name FROM v_IzPrivlIsp ORDER BY Name", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 13); Dgv1.Columns[5].DefaultCellStyle.Format = "dd.MM.yyyy"; for (int i = 12; i < Dgv1.Columns.Count; i++) { //Dgv1.Columns[i].DefaultCellStyle.Format = "# ###.###"; Dgv1.Columns[i].DefaultCellStyle.ForeColor = Color.Blue; } my.naimDG(h, Dgv1, w); Dgv1.AllowUserToAddRows = false; Dgv1.EditMode = DataGridViewEditMode.EditProgrammatically; da = new SqlDataAdapter("SELECT IdKPOSR, DateBeg, Prodol, IdIsp, IdEdIzm, Vol, IdPr, Sdvig, IdPosl, Usl FROM dbo.tKPOSR", my.sconn); SqlCommandBuilder cb = new SqlCommandBuilder(da); cb.QuotePrefix = "["; cb.QuoteSuffix = "]"; da.UpdateCommand = cb.GetUpdateCommand(); }
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; } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (WithUp) { if (ds.HasChanges()) { if (MessageBox.Show("Сохранить измененные данные?", "Внимание!", MessageBoxButtons.YesNo) == DialogResult.Yes) { my.Up(da[0], ds.Tables[0]); } } } ds = new DataSet(); string sel = ""; if (treeView1.SelectedNode.Text != "") { TreeNode tn = treeView1.SelectedNode; Dgv1.AllowUserToAddRows = false; switch (tn.Level.ToString()) { case "0": sel = my.FilterSel(72, null, my.sconn, ""); break; case "1": sel = my.FilterSel(59, null, my.sconn, "") + " where idGrComplex = " + e.Node.Tag.ToString(); break; case "2": sel = my.FilterSel(60, null, my.sconn, "") + " where idComplex = " + (Convert.ToInt16(e.Node.Tag) - 100).ToString(); break; case "3": sel = my.FilterSel(61, null, my.sconn, "") + " and idcomplexchapter = " + (Convert.ToInt16(e.Node.Tag) - 5000).ToString(); break; case "4": sel = my.FilterSel(71, null, my.sconn, "") + " where idosr = " + (Convert.ToInt16(e.Node.Tag) - 1000).ToString();; break; default: sel = ""; break; } //MessageBox.Show(tn.Level.ToString()); if (sel != "") { da[0] = new SqlDataAdapter(); DaDs dads1 = new DaDs(); //dads1.DaInd(0, "select * from Portal.dbo.tGrafik", my.sconn, "", ds, true); dads1.DaInd(0, "set language 'русский' " + sel, my.sconn, "", ds, true); da[0] = dads1.Da[0]; dv = new DataView(); dv.Table = ds.Tables[0]; //Dgv1.DataSource = null; Dgv1.DataSource = dv; my.naimDG(my.headStr, Dgv1, my.widthStr); switch (tn.Level.ToString()) { case "2": Dgv1.VLadd("главы", "Главы", "SELECT idChapter, NMChapter FROM Sprav.dbo.tsChapter order by NMChapter", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 2); break; case "3": Dgv1.VLadd("договор", "Договор", "SELECT TOP(100) PERCENT idDog, RegNomer FROM Sprav.dbo.Dogovor where iddog = 0 or iddog in (SELECT DISTINCT dbo.Forma2.IdDog FROM dbo.Forma2 INNER JOIN Sprav.dbo.tSmeti ON dbo.Forma2.IdSm = Sprav.dbo.tSmeti.IdSm INNER JOIN Sprav.dbo.tsOSR ON Sprav.dbo.tSmeti.IdOsr = Sprav.dbo.tsOSR.idOSR INNER JOIN Sprav.dbo.tComplexChapter ON Sprav.dbo.tsOSR.idComplexChapter = Sprav.dbo.tComplexChapter.idComplexChapter) ORDER BY RegNomer", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 10); break; case "4": Dgv1.VLadd("объект", "Объект", "SELECT IdObj, Name FROM Sprav.dbo.SprObject order by Name", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 2); break; } my.naimDG(my.headStr, Dgv1, my.widthStr); } } else { Dgv1.DataSource = null; } }
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; } }
public void spisok(string szap) { try { String sel; if (szap == "") { szap = szap1; } Cursor = Cursors.WaitCursor; ds = new DataSet(); if (nbut1 == 3000) { sel = szap; } else { sel = my.FilterSel(nbut1, this, my.sconn, szap); } da[0] = new SqlDataAdapter(); DaDs dads1 = new DaDs(); dads1.DaInd(0, "set language 'русский' " + sel, my.sconn, "", ds, Withup); if (Withup) { da[0] = dads1.Da[0]; } dv = new DataView(); dv.Table = ds.Tables[0]; //Dgv1.DataSource = null; Dgv1.DataSource = dv; if (nbut1 == 704) { Dgv1.VLadd("idgp", "Генподрядчик", "SELECT IdEntpr, shNMEntpr FROM sprav.dbo.tsEntpr ORDER BY shNMEntpr", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 6); Dgv1.VLadd("idinvzak", "Фактический заказчик", "SELECT idInvZak, NMInvZak FROM Sprav.dbo.tsInvZak", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 7); Dgv1.VLadd("idotv", "Ответственный", "SELECT IdEntpr, shNMEntpr FROM sprav.dbo.tsEntpr ORDER BY shNMEntpr", my.sconn, SMRC.DGVt.TypeVL.ComboBox, 8); } if (nbut1 == 8) { if (Dgv1.Columns.Count == dv.Table.Columns.Count) { CreateButton(); my.naimDG(my.headStr, Dgv1, my.widthStr); } } else if (my.widthStr != null) { my.naimDG(my.headStr, Dgv1, my.widthStr); } head = my.headStr; width1 = my.widthStr; Cursor = Cursors.Default; tslCount.Text = "Всего: " + ((int)Dgv1.Rows.Count - (Dgv1.AllowUserToAddRows ? 1 : 0)).ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); //throw; } }