示例#1
0
        private void idComplex_SelectedIndexChanged(object sender, EventArgs e)
        {
            //return;
            if (my.IsNumeric(idComplex.SelectedValue))
            {
                if (ds != null && ds.HasChanges())
                {
                    my.Up(da[0], ds.Tables[0]);
                }
                DataView dv;
                ds    = new DataSet();
                da[0] = new SqlDataAdapter();
                DaDs   dads1 = new DaDs();
                string sel   = my.FilterSel(703, null, my.sconn, " and 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 WHERE     (Sprav.dbo.tComplexChapter.idComplex = " + idComplex.SelectedValue + ") OR   (dbo.Forma2.IdDog = 0))");
                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;
                Dgv1.Columns[0].Visible = false;

                // my.MySpisok(703, " and 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 WHERE     (Sprav.dbo.tComplexChapter.idComplex = " + idComplex.SelectedValue + ") OR   (dbo.Forma2.IdDog = 0))",this,Dgv1);
            }
        }
示例#2
0
        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;
            }
        }
示例#3
0
文件: frmOSR.cs 项目: jane-safr/SMRC
        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;
            }
        }
示例#4
0
        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;
            }
        }
示例#5
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;
            }
        }