コード例 #1
0
ファイル: Form1.cs プロジェクト: SmokeVLG/FormationOfSchedule
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int focused_row = 0;
            if (link == "INS")
            {

                if (tb_PFM.Text == "" || tb_finpos.Text == "" || tb_summ.Text == "")
                {
                    lb_status.Text = "Ошибка: Заполните поля Код ПФМ, Финансовая позиция и Сумма!";
                }

                else
                {
                    DataSaver ds = new DataSaver(login_, password_);
                    lb_status.Text = ds.AddLimits
                                                (tb_PFM.Text.Replace(" ", "")
                                                , tb_finpos.Text.Replace(" ", "")
                                                , tb_year.Text.Replace(" ", "")
                                                 , cb_month.SelectedValue.ToString()
                                                 , tb_summ.Text.Replace(separator_false, separator_true).Replace(" ", "")
                                                );
                }

                tb_PFM.Text = "";
                tb_year.Text = "";
                tb_finpos.Text = "";
                tb_summ.Text = "";
                focused_row = limitsView.RowCount;
            }

            if (link == "UPD")
            {
                focused_row = limitsView.FocusedRowHandle;
                if (tb_PFM.Text == "" || tb_finpos.Text == "" || tb_summ.Text == "")
                {
                    lb_status.Text = "Ошибка: Заполните поля Код ПФМ, Финансовая позиция и Сумма!";
                }

                else
                {
                    DataSaver ds = new DataSaver(login_, password_);
                    lb_status.Text = ds.UpdateLimits
                                                (tb_PFM.Text.Replace(" ", "")
                                                , tb_finpos.Text.Replace(" ", "")
                                                , tb_year.Text.Replace(" ", "")
                                                 , cb_month.SelectedValue.ToString()
                                                 , tb_summ.Text.Replace(separator_false, separator_true).Replace(" ", "")
                                                 ,tb_id.Text
                                                );
                }

            }

            if (link == "DEL")
            {
                try
                {
                    if (limitsView.FocusedRowHandle != limitsView.RowCount - 1)
                        focused_row = limitsView.FocusedRowHandle;
                    else
                        focused_row = limitsView.FocusedRowHandle - 1;
                }
                catch { }
                string idRow = "";
                idRow = limitsView.GetFocusedDataRow()["limID"].ToString();
                DataSaver ds = new DataSaver(login_, password_);
                lb_status.Text = ds.DeleteLimits(idRow);

                _connection.Close();
            }

            LimitsFill();
            limitsView.FocusedRowHandle = focused_row;
        }