public void Update(CommonAssets commonAssets)
        {
            SQLiteConnection sqlite_conn;
            SQLiteCommand    sqlite_cmd;

            sqlite_conn = new SQLiteConnection(DataProvider.SQLiteConnectionString);
            sqlite_conn.Open();
            sqlite_cmd = sqlite_conn.CreateCommand();

            StringBuilder commandText = new StringBuilder();

            commandText.Append("UPDATE ОсновныеСредства SET ");

            DataProvider.AddCommandTextUpdate(commandText, "Наименование", commonAssets.Name);
            DataProvider.AddCommandTextUpdate(commandText, "ДатаОплаты", DataProvider.ConvertDateToSQLiteFormat(commonAssets.BillingDate));
            DataProvider.AddCommandTextUpdate(commandText, "ПервоначальнаяСтоимостьОбъекта", commonAssets.InitialCost);
            DataProvider.AddCommandTextUpdate(commandText, "СрокПолезногоИспользованияОбъекта", commonAssets.ObjectsUsefulLife);
            DataProvider.AddCommandTextUpdate(commandText, "ОстаточнаяСтоимостьОбъекта", commonAssets.ObjectsResidualValue);
            DataProvider.AddCommandTextUpdate(commandText, "КоличествоПолугодийЭксплуатацииОбъекта", commonAssets.NumberOfSemesters);
            DataProvider.AddCommandTextUpdate(commandText, "ДоляСтоимостиОбъектаЗаНалоговыйПериод", commonAssets.ObjectsProportionOfValue);
            DataProvider.AddCommandTextUpdate(commandText, "ВключеноВРасходы", commonAssets.IncludedInCosts);
            DataProvider.AddCommandTextUpdate(commandText, "ДатаВыбытия", DataProvider.ConvertDateToSQLiteFormat(commonAssets.DisposalDate));
            DataProvider.AddCommandTextUpdate(commandText, "ДатаПодачиДокументов", DataProvider.ConvertDateToSQLiteFormat(commonAssets.DocumentsDate));
            DataProvider.AddCommandTextUpdate(commandText, "ДатаВводаВЭксплуатацию", DataProvider.ConvertDateToSQLiteFormat(commonAssets.ExpluatationDate), last: true);

            commandText.Append(" WHERE Индекс = " + commonAssets.GetInternalIndex() + ";");

            sqlite_cmd.CommandText = commandText.ToString();
            sqlite_cmd.ExecuteNonQuery();
            sqlite_conn.Close();
        }
Exemple #2
0
        private void editCommonAssetsButton_Click(object sender, EventArgs e)
        {
            string internalIndex = commonAssets.GetInternalIndex();

            commonAssets = new CommonAssets();
            commonAssets.SetInternalIndex(internalIndex);

            if (includedInCostsTextBox.Text == String.Empty)
            {
                includedInCostsTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                includedInCostsTextBox.BackColor = SystemColors.Window;
            }

            if (initialCostTextBox.Text == "")
            {
                initialCostTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                initialCostTextBox.BackColor = SystemColors.Window;
            }

            if (nameTextBox.Text == "")
            {
                nameTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                nameTextBox.BackColor = SystemColors.Window;
            }

            if (numberOfSemestersTextBox.Text == "")
            {
                numberOfSemestersTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                numberOfSemestersTextBox.BackColor = SystemColors.Window;;
            }

            if (objectsProportionOfValueTextBox.Text == "")
            {
                objectsProportionOfValueTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                objectsProportionOfValueTextBox.BackColor = SystemColors.Window;
            }

            if (objectsResidualValueTextBox.Text == "")
            {
                objectsResidualValueTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                objectsResidualValueTextBox.BackColor = SystemColors.Window;
            }

            if (objectsUsefulLifeTextBox.Text == "")
            {
                objectsUsefulLifeTextBox.BackColor = Constants.badFieldColor;
            }
            else
            {
                objectsUsefulLifeTextBox.BackColor = SystemColors.Window;
            }

            if (includedInCostsTextBox.Text == "" ||
                initialCostTextBox.Text == "" ||
                nameTextBox.Text == "" ||
                numberOfSemestersTextBox.Text == "" ||
                objectsProportionOfValueTextBox.Text == "" ||
                objectsResidualValueTextBox.Text == "" ||
                objectsUsefulLifeTextBox.Text == "")
            {
                MessageBox.Show("Заполните все обязательные поля перед добавлением основных средств.");
                return;
            }

            commonAssets.BillingDate              = billingDateDateTimePicker.Text;
            commonAssets.DisposalDate             = disposalTimeTextBox.Text;
            commonAssets.DocumentsDate            = documentsDateDateTimePicker.Text;
            commonAssets.ExpluatationDate         = expluatationDateDateTimePicker.Text;
            commonAssets.IncludedInCosts          = includedInCostsTextBox.Text;
            commonAssets.InitialCost              = initialCostTextBox.Text;
            commonAssets.Name                     = nameTextBox.Text;
            commonAssets.NumberOfSemesters        = numberOfSemestersTextBox.Text;
            commonAssets.ObjectsProportionOfValue = objectsProportionOfValueTextBox.Text;
            commonAssets.ObjectsResidualValue     = objectsResidualValueTextBox.Text;
            commonAssets.ObjectsUsefulLife        = objectsUsefulLifeTextBox.Text;

            MainForm.programLogic.commonAssetsLogic.Update(commonAssets, INN);

            Close();
        }
Exemple #3
0
        public void Update(CommonAssets commonAssets)
        {
            OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
            OleDbCommand    myOleDbCommand    = myOleDbConnection.CreateCommand();

            string commandText = "UPDATE [Основные средства] SET ";

            commandText += "[Наименование объекта] = '";
            commandText += commonAssets.Name;
            commandText += "',";

            commandText += "[Дата оплаты объекта] = '";
            commandText += commonAssets.BillingDate;
            commandText += "',";

            commandText += "[Дата подачи документов] = '";
            commandText += commonAssets.DocumentsDate;
            commandText += "',";

            commandText += "[Дата ввода в эксплуатацию] = '";
            commandText += commonAssets.ExpluatationDate;
            commandText += "',";

            commandText += "[Первоначальная стоимость объекта] = '";
            commandText += commonAssets.InitialCost;
            commandText += "',";

            commandText += "[Срок полезного использования объекта] = '";
            commandText += commonAssets.ObjectsUsefulLife;
            commandText += "',";

            commandText += "[Остаточная стоимость объекта] = '";
            commandText += commonAssets.ObjectsResidualValue;
            commandText += "',";

            commandText += "[Количества полугодий эксплуатации объекта] = '";
            commandText += commonAssets.NumberOfSemesters;
            commandText += "',";

            commandText += "[Доля стоимости объекта  за налоговый объект] = '";
            commandText += commonAssets.ObjectsProportionOfValue;
            commandText += "',";

            commandText += "[Включено в расходы] = '";
            commandText += commonAssets.IncludedInCosts;
            commandText += "',";

            if (commonAssets.DisposalDate != "")
            {
                commandText += "[Дата выбытия] = '";
                commandText += commonAssets.DisposalDate;
                commandText += "'";
            }
            else
            {
                commandText += "[Дата выбытия] = ";
                commandText += "NULL";
                commandText += "";
            }

            commandText += " WHERE [№ п/п] = ";

            commandText += commonAssets.GetInternalIndex();

            commandText += ";";

            myOleDbCommand.CommandText = commandText;

            myOleDbConnection.Open();

            myOleDbCommand.ExecuteScalar();

            myOleDbConnection.Close();
        }