コード例 #1
0
ファイル: wnAddMenu.xaml.cs プロジェクト: koorool/LiveMonitor
        public AddMenu(int user_atr)
        {
            InitializeComponent();
            ActiveUser.wnAddMenu = this;
            projectName          = "";
            cDate.SelectedDate   = DateTime.Today;
            AddID(cbIDu1);
            tbID.Text = DataWork.GetNexID("id_of_transaction").ToString();
            update_comboboxes(ActiveUser.UserType);
            tbID.IsReadOnly = true;
            if (user_atr == 1)
            {
                scrvAdd.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
                this.Height = 370;
            }
            else
            {
                Show_second_user();
            }

            //Заполнение Controls
            tbID.PreviewKeyDown          += MoveBetweenControls;
            cbProjectName.PreviewKeyDown += MoveBetweenControls;
            cDate.PreviewKeyDown         += MoveBetweenControls;
            tbSum.PreviewKeyDown         += MoveBetweenControls;
            cbCurrency.PreviewKeyDown    += MoveBetweenControls;
            tbMarks.PreviewKeyDown       += MoveBetweenControls;
            tbNotes.PreviewKeyDown       += MoveBetweenControls;
            tbRates.PreviewKeyDown       += MoveBetweenControls;
            tbRKO.PreviewKeyDown         += MoveBetweenControls;
            cbReceiver.PreviewKeyDown    += MoveBetweenControls;
            сbWhoReceived.PreviewKeyDown += MoveBetweenControls;
            tbBank.PreviewKeyDown        += MoveBetweenControls;
            //end Controls
            Controls.Add(tbID);
            Controls.Add(cbProjectName);
            Controls.Add(cDate);
            Controls.Add(tbSum);
            Controls.Add(cbCurrency);
            Controls.Add(tbMarks);
            Controls.Add(tbNotes);
            if (ActiveUser.UserType != 1)
            {
                Controls.Add(tbRates);
                Controls.Add(tbRKO);
            }
            Controls.Add(cbReceiver);
            Controls.Add(сbWhoReceived);
            if (ActiveUser.UserType != 1)
            {
                Controls.Add(tbBank);
            }
        }
コード例 #2
0
ファイル: wnAddMenu.xaml.cs プロジェクト: koorool/LiveMonitor
        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();
                    }
                }
            }
        }