Ejemplo n.º 1
0
        private void button7_Click(object sender, EventArgs e)
        {
            string answer = "";
            if (dtp_pay_Date.Value == DateTime.Today)
            {
                string mess = "Вы уверенны, что платеж должен быть совершен сегодня?";
                string caption = "Вопрос";
                var result = MessageBox.Show(mess, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    answer = "Yes";
                }
                else answer = "No";
            }
            if (answer != "No")
            {

                //   if (dtp_pay_Date.Value == DateTime.Today)
                //      MessageBox.Show("Вы уверенны, что платеж должен быть совершен текущим днем?");

                int focused_row = 0;
                focused_row = gridView2.FocusedRowHandle;
                DataSaver ds1 = new DataSaver(login_, password_);
                inform_ = ds1.getPFM();

                string admMet = "";
                //if (inform_[0].Substring(0, 13) == "Администратор") Изменил Дороненков Г.Г. 03-06-2014 
				if ((inform_[0] != string.Empty) && (inform_[0].Substring(0, 13) == "Администратор"))
                    admMet = "0";
                else
                    admMet = "1";

                if (inform_[2] == "1" && admMet == "1")
                {
                    button7.Enabled = false;
                    lBlockMessage.Visible = true;

                    tb_pay_ContragentCode.Text = "";
                    tb_pay_Summ.Text = "";
                    tp_pay_ContractCode.Text = "";
                    dtp_pay_Date.Value = DateTime.Today;
                    tb_plan_statelikvid.Text = "";
                    tb_plan_stavrolen.Text = "";
                    tb_pay_EPL.Text = "";
                    tb_Comment.Text = "";
                }
                else
                {

                    string curs = "";
                    curs = cb_pay_Currency.SelectedValue.ToString();
                    try
                    {
                        if (operation_pay == "INS")
                        {
                            string message = "";
                            DataSaver ds = new DataSaver(login_, password_);
                            message = ds.InsertPaymentPlan(tp_pay_ContractCode.Text,
                                                                  tb_pay_ContragentCode.Text,
                                                                  tb_pay_ContragentType.Text,
                                                                  cb_pay_FinPosition.SelectedValue.ToString(),
                                                                  tb_pay_EPL.Text,
                                                                  tb_pay_PFMcode.Text.Replace(" ", ""),
                                                                  dtp_pay_Date.Text,
                                                                  curs,
                                                                  tb_pay_Summ.Text.Replace(" ", ""),
                                                                  tb_pay_SummRUB.Text,
                                                                  tb_Comment.Text
                                                                  );

                            if (message.Substring(0, 14) == "Предупреждение" || message.Substring(0, 5) == "Лимит")
                                MessageBox.Show(message);
                            else lb_status.Text = message;

                            tb_pay_ContragentCode.Text = "";
                            tb_pay_Summ.Text = "";
                            tp_pay_ContractCode.Text = "";
                            dtp_pay_Date.Value = DateTime.Today;
                            tb_plan_statelikvid.Text = "";
                            tb_plan_stavrolen.Text = "";
                            tb_pay_EPL.Text = "";
                            tb_Comment.Text = "";
                            focused_row = gridView2.RowCount;
                        }

                        else if (operation_pay == "UPD")
                        {
                            focused_row = gridView2.FocusedRowHandle;
                            DataSaver ds = new DataSaver(login_, password_);
                            lb_status.Text = ds.UpdatePaymentPlan(tp_pay_ContractCode.Text,
                                                                  tb_pay_ContragentCode.Text,
                                                                  tb_pay_ContragentType.Text,
                                                                  cb_pay_FinPosition.SelectedValue.ToString(),
                                                                  tb_pay_EPL.Text,
                                                                  tb_pay_PFMcode.Text.Replace(" ", ""),
                                                                  dtp_pay_Date.Text,
                                                                  curs,
                                                                  tb_pay_Summ.Text.Replace(" ", ""),
                                                                  tb_pay_SummRUB.Text,
                                                                  tb_pay_id.Text,
                                                                  tb_Comment.Text,
                                                                  admMet
                                                                  );
                        }

                        else if (operation_pay == "DEL")
                        {
                            try
                            {
                                if (gridView2.FocusedRowHandle != gridView2.RowCount - 1)
                                    focused_row = gridView2.FocusedRowHandle;
                                else
                                    focused_row = gridView2.FocusedRowHandle - 1;
                            }
                            catch { }
                            DataSaver ds = new DataSaver(login_, password_);
                            lb_status.Text = ds.DeletePayments(tb_pay_id.Text);

                        }
                    }
                    catch
                    {
                        lb_status.Text = "Ошибка: Заполнены не все поля!!!";
                    }
                    PlansFill();
                    gridView2.FocusedRowHandle = focused_row;
                    link_Payment_add_W.LinkVisited = false;
                }
            }
        }