示例#1
0
        private string HashKolAndId(List <DetalizedCl.IdAndKol> idAndKol)
        {
            try
            {
                string hashKolAndId = "";

                if (NogroupList != null && NogroupList.Count > 0 && idAndKol != null && idAndKol.Count > 0)
                {
                    foreach (DetalizedCl.IdAndKol idAndKOl in idAndKol)
                    {
                        FromDataBaseWide fromBaseId = NogroupList.FirstOrDefault <FromDataBaseWide>(fr => fr.Id == idAndKOl.Id);
                        if (fromBaseId != null && fromBaseId.Id > 0)
                        {
                            hashKolAndId += fromBaseId.IdBase + ":" + idAndKOl.Kolic + ";";
                        }
                        else
                        {
                            MessageBox.Show("Элементу с ID " + idAndKOl.Id + " не присвоен ID базы", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return("");
                        }
                    }
                    if (hashKolAndId.Length > 0)
                    {
                        hashKolAndId = hashKolAndId.Substring(0, hashKolAndId.Length - 1);
                    }
                }

                return(hashKolAndId);
            }
            catch (Exception ex)
            {
                throw new Exception("HashKolAndId", ex);
            }
        }
示例#2
0
        //public List<VedTableCl.VedTableForSave> VedTableP
        //{
        //    get { return vedTableP.VedTableP; }
        //}


        public PodKlassForm(FromDataBaseWide sveraP)
        {
            InitializeComponent();

            this.sveraP = sveraP;
            podKlassP   = new PodKlassCl(sveraP.TipOborud);

            chekList.Items.Clear();

            List <PodKlassFromDataBase> masOfDan = podKlassP.DataFromDb;

            chekList.DataSource = masOfDan;

            foreach (var pd in sveraP.PodklassL)
            {
                int ind = masOfDan.FindIndex(m => m.Naim == pd.Naim);
                if (ind > -1)
                {
                    chekList.SetItemChecked(ind, true);
                }
            }

            SizeChange();
            load = true;
        }
示例#3
0
        public void AddRowinFromBase(FromDataBase svGr)
        {
            FromDataBaseWide fromDataBaseWide = new FromDataBaseWide();

            fromDataBaseWide.ChangeDataBaseWide(svGr);
            fromDataBaseWide.Id = ++idCounter;

            FromDataBaseCl.Add(fromDataBaseWide);
        }
示例#4
0
 public SveraBaseChange()
 {
     try
     {
         colList                  = SveraParam.GetColumns();
         rowNamesShort            = SveraParam.GetRows(true, false);
         fromDataBaseWideForSvera = new FromDataBaseWide();
         UpdateDatabase();
     }
     catch (Exception ex)
     {
         throw new Exception("SveraBaseChange", ex);
     }
 }
示例#5
0
 public FindAndChangeCl(List <FromDataBaseWide> fromDataBaseWideSveraCl, bool autocad)
 {
     try
     {
         this.fromDataBaseWideSveraCl = fromDataBaseWideSveraCl;
         colList = GetColumns();
         rowList = SveraParam.GetRows(false, autocad);
         fromDataBaseWideForSvera = new FromDataBaseWide();
     }
     catch (Exception ex)
     {
         throw new Exception("FindAndChangeCl", ex);
     }
 }
示例#6
0
        public SverParamForm(List <FromDataBaseWide> fromDataBaseWide, Form Owner)
        {
            InitializeComponent();

            try
            {
                if (Svera.Properties.Settings.Default.SverParamSize != new Size(0, 0))
                {
                    this.Size = Svera.Properties.Settings.Default.SverParamSize;
                }
                //if (Svera.Properties.Settings.Default.SverParamLocation != new Point(0, 0))
                //{
                //    this.Location = Svera.Properties.Settings.Default.SverParamLocation;
                //}

                sveraP = new SveraParam(FromDataBaseWide.CompleteFromList(fromDataBaseWide), false);

                if (SveraP.ColList.Count > 0)
                {
                    DataGridViewColumn[] dataGridColSver = new DataGridViewColumn[SveraP.ColList.Count];
                    ColumnNames          colName;

                    for (int i = 0; i <= SveraP.ColList.Count - 1; i++)
                    {
                        colName                       = SveraP.ColList[i];
                        dataGridColSver[i]            = new DataGridViewTextBoxColumn();
                        dataGridColSver[i].Name       = colName.nameColumn;
                        dataGridColSver[i].HeaderText = colName.textColumn;
                        dataGridColSver[i].SortMode   = DataGridViewColumnSortMode.NotSortable;
                        //if (i == 0)
                        //{
                        dataGridColSver[i].ReadOnly = colName.readOnly;
                        //}
                    }

                    sverPDataGrid.Columns.AddRange(dataGridColSver);
                    sverPDataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                    sverPDataGrid.Columns[SveraParam.ColDatagridNames.Value].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                }

                if (SveraP.RowList.Count > 0)
                {
                    DataGridViewRow[] dataGridRowSver = new DataGridViewRow[SveraP.RowList.Count];
                    RowsNames         rowName;

                    for (int i = 0; i <= SveraP.RowList.Count - 1; i++)
                    {
                        rowName            = SveraP.RowList[i];
                        dataGridRowSver[i] = new DataGridViewRow();
                        dataGridRowSver[i].CreateCells(sverPDataGrid);

                        if (SveraP.RowList[i].dataCellType == typeof(DataGridViewComboBoxCell))
                        {
                            DataGridViewComboBoxCell cc = new DataGridViewComboBoxCell();
                            cc.FlatStyle = FlatStyle.Flat;
                            if (SveraP.RowList[i].ArrayValue != null)
                            {
                                cc.Items.AddRange(SveraP.RowList[i].ArrayValue);
                            }
                            dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Value].Index] = cc;
                        }
                        dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Parametr].Index].Value = SveraP.RowList[i].textRow;
                        dataGridRowSver[i].Tag = SveraP.RowList[i].nameRow;

                        if (SveraP.RowList[i].readonlyT == true)
                        {
                            dataGridRowSver[i].ReadOnly = true;
                        }

                        if (SveraP.RowList[i].redact == true)
                        {
                            DataGridViewButtonCell bb = new DataGridViewButtonCell();
                            bb.FlatStyle       = FlatStyle.Flat;
                            bb.Value           = "Ред.";
                            bb.Style.BackColor = Color.LightGray;
                            dataGridRowSver[i].Cells[sverPDataGrid.Columns[SveraParam.ColDatagridNames.Redact].Index] = bb;
                        }
                    }

                    sverPDataGrid.Rows.AddRange(dataGridRowSver);
                }
                ChangeSpec();
                SizeChange();

                load = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    MessageBox.Show(ex.InnerException.ToString());
                }
            }
        }
示例#7
0
        public void CreateOrUpdateGr(DataBaseMotion motion, int index, SveraGrFormDataBase sveraGrDataBase)
        {
            SQLiteConnection SQLconnect = null;
            SQLiteCommand    command    = null;

            try
            {
                string filePath = FunctionUse.GetDataBasePath();
                if (File.Exists(filePath) == true)
                {
                    FunctionUse.CopyDataBase(filePath);

                    SQLconnect = new SQLiteConnection();
                    SQLconnect.ConnectionString  = "Data Source=" + FunctionUse.GetDataBasePath() + ";";
                    SQLconnect.ParseViaFramework = true;
                    SQLconnect.Open();

                    using (var transaction = SQLconnect.BeginTransaction())
                    {
                        string sqlCom = "";

                        FunctionUse.TestTableAndColumns(SQLconnect);

                        if (motion == DataBaseMotion.Delete)
                        {
                            if (sveraGrDataBase != null && sveraGrDataBase.IdBase > 0)
                            {
                                sqlCom = "DELETE FROM GroupTable " +
                                         "WHERE Id = " + sveraGrDataBase.IdBase
                                ;
                            }
                            else
                            {
                                MessageBox.Show("Текущая запись не существует", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                        else
                        {
                            FromDataBaseWide detilizeId = GroupList.FirstOrDefault <FromDataBaseWide>(fr => fr.Id == Detalized[index].Id);


                            if (detilizeId != null && detilizeId.IdBase > 0)
                            {
                                //string insertTest = "WHERE NOT EXISTS  (SELECT 1 FROM GroupTable WHERE " +
                                //                                        "naimId = " + detilizeId.IdBase +
                                //                                        ")";
                                sqlCom = "INSERT OR REPLACE" +
                                         " INTO GroupTable (id, naimId, groupId) " +
                                         "SELECT " +
                                         ((motion == DataBaseMotion.Insert) ? "NULL" : sveraGrDataBase.IdBase.ToString()) +
                                         ", " + detilizeId.IdBase + "" +
                                         ", '" + HashKolAndId(Detalized[index].GridGroupId) + "'" //+
                                                                                                  //   " " +
                                                                                                  // ((motion == DataBaseMotion.Insert) ? insertTest : "")
                                ;
                            }
                            else
                            {
                                MessageBox.Show("Текущей группе не присвоен ID базы", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        command = new SQLiteCommand(sqlCom, SQLconnect);
                        command.ExecuteNonQuery();

                        transaction.Commit();

                        if (motion == DataBaseMotion.Insert)
                        {
                            MessageBox.Show("Запись добавлена в базу", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (motion == DataBaseMotion.Update)
                        {
                            MessageBox.Show("Запись обновлена в базе", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (motion == DataBaseMotion.Delete)
                        {
                            MessageBox.Show("Запись удалена из базы", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }

                    if (command != null)
                    {
                        command.Dispose();
                    }
                    if (SQLconnect != null)
                    {
                        SQLconnect.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                if (SQLconnect != null)
                {
                    SQLconnect.Close();
                }
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    MessageBox.Show(ex.InnerException.ToString());
                }
            }
        }
示例#8
0
        private void addrowInSpec(CopyToClipboard cpc, FromDataBaseWide rowGrid, string[,] oTableStr, Microsoft.Office.Interop.Excel.Worksheet oSheet, ref int needOfRow)
        {
            try
            {
                if (rowGrid.PosicToExp > 0)
                {
                    oTableStr[needOfRow, 0] = (rowGrid.PosicToExp).ToString();
                }
                oTableStr[needOfRow, 1] = rowGrid.Naim;

                oTableStr[needOfRow, 2] = rowGrid.MarkaOborud;
                if (rowGrid.DocObozn != null && rowGrid.DocObozn != "")
                {
                    if (oTableStr[needOfRow, 2] != null && oTableStr[needOfRow, 2] != "")
                    {
                        oTableStr[needOfRow, 2] += (char)10;
                    }
                    oTableStr[needOfRow, 2] += rowGrid.DocObozn;
                }

                string prim = "";
                if (rowGrid.Markirov != null && rowGrid.Markirov != "")
                {
                    prim += rowGrid.Markirov + (char)10;
                }
                prim += rowGrid.PrimWord;

                int startInd = rowGrid.KolicByDetalizeList.Count - 3;
                if (startInd < 0)
                {
                    startInd = 0;
                }
                int endInd = startInd + 2;
                if (endInd > rowGrid.KolicByDetalizeList.Count - 1)
                {
                    endInd = rowGrid.KolicByDetalizeList.Count - 1;
                }

                var rowRange = rowGrid.KolicByDetalizeList.GetRange(startInd, endInd - startInd + 1);

                if (cpc.ExportP.TipSpec == SveraExportParam.RowsDatagridExportNames.TipSpecAndVed.standart)
                {
                    oTableStr[needOfRow, 3] = rowGrid.Kod;
                    oTableStr[needOfRow, 4] = rowGrid.Postav;
                    oTableStr[needOfRow, 5] = rowGrid.EdIzmW;
                    if (rowGrid.KolicByDetalizeR > 0)
                    {
                        oTableStr[needOfRow, 6] = Math.Round((rowGrid.KolicByDetalizeR * rowGrid.KoefToWord), 3).ToString();
                    }
                    if (rowGrid.Massa > 0)
                    {
                        oTableStr[needOfRow, 7] = rowGrid.Massa.ToString();
                    }

                    oTableStr[needOfRow, 8] = prim;
                }
                else if (cpc.ExportP.TipSpec == SveraExportParam.RowsDatagridExportNames.TipSpecAndVed.rev)
                {
                    oTableStr[needOfRow, 3] = rowGrid.EdIzmW;

                    if (rowRange.Count >= 1 && rowRange[0] > 0)
                    {
                        oTableStr[needOfRow, 4] = Math.Round((rowRange[0] * rowGrid.KoefToWord), 3).ToString();
                    }

                    if (rowRange.Count >= 2 && rowRange[1] > 0)
                    {
                        double dif = Math.Round((rowRange[1] - rowRange[0]) * rowGrid.KoefToWord, 3);
                        oTableStr[needOfRow, 6] = Svera.DopFunctions.PlusAdd(dif).ToString();
                        oTableStr[needOfRow, 7] = Math.Round((rowRange[1] * rowGrid.KoefToWord), 3).ToString();
                    }

                    if (rowRange.Count >= 3 && rowRange[2] > 0)
                    {
                        double dif = Math.Round((rowRange[2] - rowRange[1]) * rowGrid.KoefToWord, 3);
                        oTableStr[needOfRow, 8] = Svera.DopFunctions.PlusAdd(dif);
                        oTableStr[needOfRow, 9] = Math.Round((rowRange[2] * rowGrid.KoefToWord), 3).ToString();
                    }

                    if (rowGrid.Massa > 0)
                    {
                        oTableStr[needOfRow, 5] = rowGrid.Massa.ToString();
                    }

                    if (rowGrid.Markirov != null && rowGrid.Markirov != "")
                    {
                        oTableStr[needOfRow, 10] += rowGrid.Markirov + (char)10;
                    }



                    if (prim != "")
                    {
                        prim += (char)10;
                    }
                    prim += rowGrid.Postav;
                    oTableStr[needOfRow, 10] += prim;
                }



                needOfRow += 1;
            }
            catch (Exception ex)
            {
                throw new Exception("addrowInSpec", ex);
            }
        }
示例#9
0
        private void addrowInVed(CopyToClipboard cpc, FromDataBaseWide rowGrid, string[,] oTableStr, Microsoft.Office.Interop.Excel.Worksheet oSheet, ref int needOfRow)
        {
            try
            {
                if (rowGrid.Posic > -1 | rowGrid.RowTypes == RowsType.GroupELemWithNumber)
                {
                    if (rowGrid.RowTypes == RowsType.Standart | rowGrid.RowTypes == RowsType.GroupELemWithNumber)
                    {
                        counterRow += 1;
                        oTableStr[needOfRow, 0] = counterRow.ToString();
                    }
                    else
                    {
                        oTableStr[needOfRow, 0] = "";
                    }
                }


                if (rowGrid.RowTypes == RowsType.Standart)
                {
                    oTableStr[needOfRow, 1] = rowGrid.VedRabot;
                    if (rowGrid.MarkaOborud != null && rowGrid.MarkaOborud != "")
                    {
                        oTableStr[needOfRow, 1] += " " + rowGrid.MarkaOborud;
                    }
                }
                else
                {
                    oTableStr[needOfRow, 1] = rowGrid.Naim;
                }

                oTableStr[needOfRow, 2] = rowGrid.EdIzm;


                int startInd = rowGrid.KolicByDetalizeList.Count - 5;
                if (startInd < 0)
                {
                    startInd = 0;
                }
                int endInd = startInd + 4;
                if (endInd > rowGrid.KolicByDetalizeList.Count - 1)
                {
                    endInd = rowGrid.KolicByDetalizeList.Count - 1;
                }

                var rowRange = rowGrid.KolicByDetalizeList.GetRange(startInd, endInd - startInd + 1);
                if (cpc.ExportP.TipSpec == SveraExportParam.RowsDatagridExportNames.TipSpecAndVed.standart)
                {
                    if (rowGrid.KolicByDetalizeR > 0)
                    {
                        oTableStr[needOfRow, 3] = Math.Round(rowGrid.KolicByDetalizeR, 3).ToString();
                    }
                }
                else if (cpc.ExportP.TipSpec == SveraExportParam.RowsDatagridExportNames.TipSpecAndVed.rev)
                {
                    if (rowRange.Count >= 1 && rowRange[0] > 0)
                    {
                        oTableStr[needOfRow, 3] = Math.Round((rowRange[0] * rowGrid.KoefToWord), 3).ToString();
                    }


                    if (rowRange.Count >= 2 && rowRange[1] > 0)
                    {
                        double dif = Math.Round((rowRange[1] - rowRange[0]) * rowGrid.KoefToWord, 3);
                        oTableStr[needOfRow, 5] = Svera.DopFunctions.PlusAdd(dif);
                        oTableStr[needOfRow, 6] = Math.Round((rowRange[1] * rowGrid.KoefToWord), 3).ToString();
                    }


                    if (rowRange.Count >= 3 && rowRange[2] > 0)
                    {
                        double dif = Math.Round((rowRange[2] - rowRange[1]) * rowGrid.KoefToWord, 3);
                        oTableStr[needOfRow, 7] = Svera.DopFunctions.PlusAdd(dif);
                        oTableStr[needOfRow, 8] = Math.Round((rowRange[2] * rowGrid.KoefToWord), 3).ToString();
                    }


                    if (rowRange.Count >= 4 && rowRange[3] > 0)
                    {
                        double dif = Math.Round((rowRange[3] - rowRange[2]) * rowGrid.KoefToWord, 3);
                        oTableStr[needOfRow, 9]  = Svera.DopFunctions.PlusAdd(dif);
                        oTableStr[needOfRow, 10] = Math.Round((rowRange[3] * rowGrid.KoefToWord), 3).ToString();
                    }


                    if (rowRange.Count >= 5 && rowRange[4] > 0)
                    {
                        double dif = Math.Round((rowRange[4] - rowRange[2]) * rowGrid.KoefToWord, 3);
                        oTableStr[needOfRow, 11] = Svera.DopFunctions.PlusAdd(dif);
                        oTableStr[needOfRow, 12] = Math.Round((rowRange[4] * rowGrid.KoefToWord), 3).ToString();
                    }
                }

                needOfRow += 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                throw new Exception("addrowInSpec", ex);
            }
        }