示例#1
0
        private void Login( object sender, RoutedEventArgs args )
        {
            //here login
            try
            {
                //DataWork._ConnectionString = ConfigurationManager.ConnectionStrings
                //["AdamDbCon"].ConnectionString;
                 DataWork._ConnectionString = "Data Source=10.111.0.101\\SQLEXPRESS;Initial Catalog=AdamDB;Persist Security Info=True;User ID=AdminNew;Password=ddaedeqq";
                int type = DataWork.GetUsersType(tbLogin.Text, tbPassword.Password);
                if (type == 0) throw new Exception("Логин/пароль не совпадают");
                if (type == -1) throw new Exception("Нет соединения. Запустите Kerio VPN Client и выполните подключение к серверу. Затем, попробуйте снова.");
                    if (!DataWork.If_checked(tbLogin.Text, tbPassword.Password))
                    {
                        ActiveUser.dt_log.Start();
                        DataWork.CheckIn(tbLogin.Text, tbPassword.Password);
                        ActiveUser.login = tbLogin.Text;
                        ActiveUser.password = tbPassword.Password;
                        ActiveUser.UserType = type;

                        Window wn = new MainWindow(type);
                        wn.Show();
                        this.Close();
                    }
            }
            catch (Exception e)
            {
                Window wn = new wnError(e.Message, 1);
                wn.ShowDialog();
            }
        }
示例#2
0
        private void Login(object sender, RoutedEventArgs args)
        {
            //here login
            try
            {
                //DataWork._ConnectionString = ConfigurationManager.ConnectionStrings
                //["AdamDbCon"].ConnectionString;
                DataWork._ConnectionString = "Data Source=10.111.0.101\\SQLEXPRESS;Initial Catalog=AdamDB;Persist Security Info=True;User ID=AdminNew;Password=ddaedeqq";
                int type = DataWork.GetUsersType(tbLogin.Text, tbPassword.Password);
                if (type == 0)
                {
                    throw new Exception("Логин/пароль не совпадают");
                }
                if (type == -1)
                {
                    throw new Exception("Нет соединения. Запустите Kerio VPN Client и выполните подключение к серверу. Затем, попробуйте снова.");
                }
                if (!DataWork.If_checked(tbLogin.Text, tbPassword.Password))
                {
                    ActiveUser.dt_log.Start();
                    DataWork.CheckIn(tbLogin.Text, tbPassword.Password);
                    ActiveUser.login    = tbLogin.Text;
                    ActiveUser.password = tbPassword.Password;
                    ActiveUser.UserType = type;

                    Window wn = new MainWindow(type);
                    wn.Show();
                    this.Close();
                }
            }
            catch (Exception e)
            {
                Window wn = new wnError(e.Message, 1);
                wn.ShowDialog();
            }
        }
示例#3
0
        private void SubmitAdd(object sender, RoutedEventArgs e)
        {
            int count = 0;

            if (ActiveUser.UserType == 1)
            {
                if (tcID.SelectedIndex == 0)
                {
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbSum.Text != ""))
                    {
                        if (tbNotes.Text == "")
                        {
                            tbNotes.Text = " ";
                        }

                        count = DataWork.GetNexID("id_of_transaction");
                        DataWork.InsertUser1Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate.ToString()),
                                                 cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, ActiveUser.UserID);
                        DataWork.InsertUser2Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, 0, 0, tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, false);
                        Window wn = new wnError("Транзакция создана успешно", 2);
                        wn.ShowDialog();
                        tbID.Text = DataWork.GetNexID("id_of_transaction").ToString();
                        ClearFields();
                        update_comboboxes(ActiveUser.UserType);
                        cbProjectName.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", 2);
                        wn.ShowDialog();
                    }
                }
                else
                {
                    int id = Convert.ToInt32(cbIDu1.SelectedItem.ToString().Remove(0, 38));
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbSum.Text != ""))
                    {
                        if (tbNotes.Text == "")
                        {
                            tbNotes.Text = " ";
                        }

                        DataWork.UpdateUser1Info(id, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text);
                        DataWork.InsertUser2Info(Convert.ToInt32(tbID.Text), projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, 0, 0, tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, false);
                        Window wn = new wnError("Данные изменены", 2);
                        wn.ShowDialog();
                        ClearFields();
                        cbIDu1.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", 2);
                        wn.ShowDialog();
                    }
                }
            }
            else
            {
                if (tcID.SelectedIndex == 1)
                {
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbReceiver.Text != "") && (tbWhoReceived.Text != "") && (tbBank.Text != "") && (tbSum.Text != ""))
                    {
                        //string str = cbIDu1.SelectedItem.ToString().Remove(0, 38);
                        if (tbNotes.Text == "")
                        {
                            tbNotes.Text = " ";
                        }


                        DataWork.InsertUser2Info(Convert.ToInt32(cbIDu1.SelectedItem.ToString().Remove(0, 38)), projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, Convert.ToSingle(tbRKO.Text), Convert.ToSingle(tbRates.Text), tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, true);
                        Window wn = new wnError("Данные изменены", 2);
                        wn.ShowDialog();
                        ClearFields();
                        cbIDu1.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", this);
                        wn.ShowDialog();
                    }
                }
                else
                {
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbReceiver.Text != "") && (tbWhoReceived.Text != "") && (tbBank.Text != "") && (tbSum.Text != ""))
                    {
                        if (tbNotes.Text == "")
                        {
                            tbNotes.Text = " ";
                        }


                        count = DataWork.GetNexID("id_of_transaction");
                        DataWork.InsertUser1Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, ActiveUser.UserID);
                        DataWork.InsertUser2Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, Convert.ToSingle(tbRKO.Text), Convert.ToSingle(tbRates.Text), tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, false);
                        Window wn = new wnError("Транзакция создана успешно", 2);
                        wn.ShowDialog();
                        ClearFields();
                        update_comboboxes(ActiveUser.UserType);
                        tbID.Text = DataWork.GetNexID("id_of_transaction").ToString();
                        cbProjectName.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", 2);
                        wn.ShowDialog();
                    }
                }
            }
        }
示例#4
0
        private void SubmitAdd(object sender, RoutedEventArgs e)
        {
            int count = 0;
            if (ActiveUser.UserType == 1)
            {
                if (tcID.SelectedIndex == 0)
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbSum.Text != ""))
                    {
                        if (tbNotes.Text == "")
                            tbNotes.Text = " ";

                        count = DataWork.GetNexID("id_of_transaction");
                        DataWork.InsertUser1Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate.ToString()),
                            cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, ActiveUser.UserID);
                        DataWork.InsertUser2Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, 0, 0, tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, false);
                        Window wn = new wnError("Транзакция создана успешно", 2);
                        wn.ShowDialog();
                        tbID.Text = DataWork.GetNexID("id_of_transaction").ToString();
                        ClearFields();
                        update_comboboxes(ActiveUser.UserType);
                        cbProjectName.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", 2);
                        wn.ShowDialog();
                    }
                else
                {
                    int id = Convert.ToInt32(cbIDu1.SelectedItem.ToString().Remove(0, 38));
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbSum.Text != ""))
                    {
                        if (tbNotes.Text == "")
                            tbNotes.Text = " ";

                        DataWork.UpdateUser1Info(id, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text);
                        DataWork.InsertUser2Info(Convert.ToInt32(tbID.Text), projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, 0, 0, tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, false);
                        Window wn = new wnError("Данные изменены", 2);
                        wn.ShowDialog();
                        ClearFields();
                        cbIDu1.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", 2);
                        wn.ShowDialog();
                    }
                }
            }
            else
            {
                if (tcID.SelectedIndex == 1)
                {
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbReceiver.Text != "") && (tbWhoReceived.Text != "") && (tbBank.Text != "") && (tbSum.Text != ""))
                    {
                        //string str = cbIDu1.SelectedItem.ToString().Remove(0, 38);
                        if (tbNotes.Text == "")
                            tbNotes.Text = " ";

                        DataWork.InsertUser2Info(Convert.ToInt32(cbIDu1.SelectedItem.ToString().Remove(0, 38)), projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, Convert.ToSingle(tbRKO.Text), Convert.ToSingle(tbRates.Text), tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, true);
                        Window wn = new wnError("Данные изменены", 2);
                        wn.ShowDialog();
                        ClearFields();
                        cbIDu1.SelectedIndex = -1;

                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", this);
                        wn.ShowDialog();
                    }
                }
                else
                {
                    if ((projectName != "") && (cDate.SelectedDate < DateTime.Now) && (cbCurrency.SelectedIndex != -1) && (tbMarks.SelectedIndex != -1) && (tbReceiver.Text != "") && (tbWhoReceived.Text != "") && (tbBank.Text != "") && (tbSum.Text != ""))
                    {
                        if (tbNotes.Text == "")
                            tbNotes.Text = " ";

                        count = DataWork.GetNexID("id_of_transaction");
                        DataWork.InsertUser1Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, ActiveUser.UserID);
                        DataWork.InsertUser2Info(count, projectName, Convert.ToDateTime(cDate.SelectedDate), cbCurrency.SelectedItem.ToString().Remove(0, 38), Convert.ToSingle(tbSum.Text), tbMarks.Text, tbNotes.Text, Convert.ToSingle(tbRKO.Text), Convert.ToSingle(tbRates.Text), tbReceiver.Text, tbWhoReceived.Text, tbBank.Text, ActiveUser.ActiveDistribution_id, false);
                        Window wn = new wnError("Транзакция создана успешно", 2);
                        wn.ShowDialog();
                        ClearFields();
                        update_comboboxes(ActiveUser.UserType);
                        tbID.Text = DataWork.GetNexID("id_of_transaction").ToString();
                        cbProjectName.SelectedIndex = -1;
                    }
                    else
                    {
                        Window wn = new wnError("Не все поля были заполнены", 2);
                        wn.ShowDialog();
                    }
                }

            }
        }