コード例 #1
0
ファイル: AddAction.xaml.cs プロジェクト: zerosui/WPF
        private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            comboBox1.Items.Clear();
            DisplayFieldListItem item2 = (DisplayFieldListItem)this.comboBox2.SelectedItem;

            BindCombox(item2.ID);
        }
コード例 #2
0
ファイル: AddAction.xaml.cs プロジェクト: zerosui/WPF
        private void BindData()
        {
            DisplayFieldListItem item  = new DisplayFieldListItem("1", "收入");
            DisplayFieldListItem item1 = new DisplayFieldListItem("2", "支出");

            this.comboBox2.Items.Add(item);
            this.comboBox2.Items.Add(item1);
            this.comboBox2.SelectedIndex = 0;
            BindCombox("1");
            textBox3.Text = AddUser.UserName;
            textBox1.Text = "0";
        }
コード例 #3
0
ファイル: AddAction.xaml.cs プロジェクト: zerosui/WPF
 private void BindCombox(string index)
 {
     comboBox1.Items.Clear();
     using (financepersonalEntities dbEntity = new financepersonalEntities())
     {
         var Role = dbEntity.role.Where(m => m.RoleAttr == index).ToList();
         for (int i = 0; i < Role.Count; i++)
         {
             DisplayFieldListItem item2 = new DisplayFieldListItem(Role[i].RoleId.ToString(), Role[i].RoleDefine1);
             this.comboBox1.Items.Add(item2);
         }
     }
     this.comboBox1.SelectedIndex = 0;
 }
コード例 #4
0
ファイル: AddAction.xaml.cs プロジェクト: zerosui/WPF
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            DisplayFieldListItem DFL  = (DisplayFieldListItem)this.comboBox2.SelectedItem;
            DisplayFieldListItem DFL1 = (DisplayFieldListItem)this.comboBox1.SelectedItem;

            int    ActionUserID  = AddUser.UserId;
            string ActionName    = DFL.ID;
            string ActionMoney   = textBox1.Text.Trim();
            string ActionRole    = DFL1.ID;
            string ActionTime    = datePicker1.Text.Trim();
            string ActionComment = textBox6.Text.Trim();

            if (!validForm(ActionMoney, ActionTime))
            {
                Dialog.DialogWindow.CreateAlertWindow("提示", "时间及金额不可为空!", null).Show();
                return;
            }

            if (DFL.ID == "2")
            {
                ActionMoney = "-" + ActionMoney;
            }

            using (financepersonalEntities dbEntity = new financepersonalEntities())
            {
                acount ac = dbEntity.acount.Where(m => m.AcountDefine1 == AddUser.UserName).FirstOrDefault();
                ac.AcountTotal = (double.Parse(ActionMoney) + double.Parse(ac.AcountTotal)).ToString();
                dbEntity.ObjectStateManager.ChangeObjectState(ac, EntityState.Modified);

                action myAction = new action();
                myAction.ActionUserId  = ActionUserID;
                myAction.ActionCountId = ac.AcountId;
                myAction.ActionName    = ActionName;
                myAction.ActionRole    = ActionRole;
                myAction.ActionTime    = DateTime.Parse(ActionTime);
                myAction.ActionCommet  = ActionComment;
                myAction.ActionMoney   = ActionMoney;
                myAction.ActionDefine3 = "";
                dbEntity.action.AddObject(myAction);

                dbEntity.SaveChanges();
            }
            Dialog.DialogWindow.CreateAlertWindow("提示", "保存成功!", null).Show();
        }