コード例 #1
0
ファイル: Form1.cs プロジェクト: SmokeVLG/FormationOfSchedule
        public Form1(string login, string password, Form main)
        {
            InitializeComponent();
          //  _command = new OleDbCommand();
            if (_connection == null)
            {
                temp = main;
                try
                {
                    _connection = new SqlConnection(ConfigurationManager.ConnectionStrings["FormationOfSchedule.Properties.Settings.FormationOfSchedule"].ConnectionString);
                    SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
                    scsb.DataSource = _connection.DataSource;
                    scsb.InitialCatalog = _connection.Database;
                    scsb.UserID = login;
                    scsb.Password = password;
                    login_ = login;
                    password_ = password;
                    _connection = new SqlConnection(scsb.ConnectionString);
                    string[] inform = new string[3];
                    DataSaver ds = new DataSaver(login_, password_);
                    inform = ds.getPFM();
                    inform_ = inform;

                    if (inform_[2] == "1")
                    {
                        blockMark = "unlock";
                        btn_block.Text = "Разблокировать ввод ПП";
                    }
                    else
                    {
                        blockMark = "lock";
                        btn_block.Text = "Заблокировать ввод ПП";
                    }
                    
					//if (inform_[0].Substring(0, 13) != "Администратор") Изменил Дороненков Г.Г. 03-06-2014 
					if ((inform_[0] != string.Empty) && (inform_[0].Substring(0, 13) != "Администратор"))
                    {
                        //tabPage2.Enabled = false;
                        btn_del_actual.Visible = false;
                        lb_limits_file.Visible = false;
                        btn_limits_load.Visible = false;
                        groupBox3.Visible = false;
                        groupBox7.Visible = false;
                        btnAdd.Visible = false;
                        linkAdd.Visible = false;
                        linkDel.Visible = false;
                        linkChenge.Visible = false;
                       // limitsControl.Location.Y = System.Drawing.Point.
                       // limitsControl.Location = new Point(6, 10);
                       // tabPage4.Enabled = false;
                        btn_actual_load.Visible = false;
                        lb_actual_file.Visible = false;
                        gb_actual.Visible = false;
                      //  ActualControl.Location = new Point(6, 10);
                        tabPage5.Enabled = false;

                        btn_block.Visible = false;
                        otch2.Visible = false;
                        Otch3.Visible = false;
                        otch_sv.Visible = false;
                        otch5.Visible = false;
                        otch6.Visible = false;

                        dateTimePicker10.Visible = false;
                        label68.Visible = false;
                        dateTimePicker7.Visible = false;
                        label58.Visible = false;

                        if (inform_[2] == "1")
                        {
                            button7.Enabled = false;
                           // MessageBox.Show("Ввод планируемых платежей заблокирован!", "Внимание!!!");
                            lBlockMessage.Visible = true;
                        }
                    }
                    tb_pay_ContragentType.ReadOnly = true;
                    tb_pay_EPL.ReadOnly = true;
                    tb_pay_PFMcode.ReadOnly = true;
                    tb_pay_SummRUB.ReadOnly = true;
                    tb_plan_statelikvid.ReadOnly = true;
                    tb_plan_stavrolen.ReadOnly = true;
                    tb_pay_ContragentType.BackColor = System.Drawing.Color.White;
                    tb_pay_EPL.BackColor = System.Drawing.Color.White;
                    tb_pay_PFMcode.BackColor = System.Drawing.Color.White;
                    tb_pay_SummRUB.BackColor = System.Drawing.Color.White;
                    tb_plan_stavrolen.BackColor = System.Drawing.Color.White;
                    tb_plan_statelikvid.BackColor = System.Drawing.Color.White;
                    tb_pay_PFMcode.Text = inform[1];
                    TemplatePath = Directory.GetCurrentDirectory() + "\\Reports\\";

                    string separator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
                    if (separator == ".")
                    {
                        separator_true = '.';
                        separator_false = ',';
                    }
                    else
                    {
                        separator_true = ',';
                        separator_false = '.';
                    }
                }
                catch (Exception ex)
                {
                  //  MessageBox.Show("Проблема с авторизацией! Возможно у Вас нет доступа к ПО.");

                       MessageBox.Show(ex.Message);
                    StringError = "error";
                }
            }
            
            

        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: SmokeVLG/FormationOfSchedule
        public void timer1_Tick(object sender, EventArgs e)
        {
            lb_status.Text = "";
            DataSaver ds = new DataSaver(login_, password_);
            inform_ = ds.getPFM();
			//if (inform_[2] == "1" && (inform_[0].Substring(0, 13) != "Администратор"))  Изменил Дороненков Г.Г. 03-06-2014 
			if (inform_[2] == "1" && ((inform_[0] != string.Empty) && (inform_[0].Substring(0, 13) != "Администратор")))
            {
                button7.Enabled = false;
                lBlockMessage.Visible = true;
            }
            else
            {
                button7.Enabled = true;
                lBlockMessage.Visible = false;
            }

           // MessageBox.Show(DateTime.Now.ToString());

            /*
            if (DateTime.Now.ToString("HH:mm") == "13:05" || DateTime.Now.ToString("HH:mm") == "17:05")
            {
                _connection.Close();
                timer1.Stop();
                temp.Close();
            }
            */
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: SmokeVLG/FormationOfSchedule
        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;
                }
            }
        }