예제 #1
0
 //执行新增(插入)数据,或判断密码是否正确
 public int Insert(Account account)
 {
     return SqlHelper.ExecuteNonQuery(@"insert into T_Account (Id,OperatorId,Item,Money,CostType,Date,Remarks,IsDeleted)
        values(newid(),@OperatorId,@Item,@Money,@CostType,@Date,@Remarks,0)",
         new SqlParameter("@OperatorId", account.OperatorId),
         new SqlParameter("@Item", account.Item),
         new SqlParameter("@Money", account.Money),
         new SqlParameter("@CostType", account.CostType),
         new SqlParameter("@Date", account.Date),
         new SqlParameter("@Remarks", account.Remarks));
 }
예제 #2
0
 //根据用户名的GUi获取数据
 public Account[] GetByOperatorId(Guid operatorId)
 {
     DataTable table = SqlHelper.ExecuteDataTable(@"select * from T_Account where OperatorId=@OperatorId and IsDeleted=0",
         new SqlParameter("@OperatorId", operatorId));
     if (table.Rows.Count <= 0)
     {
         return null;
     }
     else
     {
         Account[] account = new Account[table.Rows.Count];
         for (int i = 0; i < table.Rows.Count; i++)
         {
             account[i] = ToAccount(table.Rows[i]);
         }
         return account;
     }
 }
예제 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            IdNameBLL idnamebll = new IdNameBLL();
            Account account = new Account();
            //获得用户的Id
            account.OperatorId = LoginWindow.GetOperatorId();

            // MessageBox.Show("执行了!");
            //添加
            if (IsAddNew)
            {

                //设置默认值
                account.Date = DateTime.Now;
                account.Money = 0;
                account.Remarks = "无";
                gridEditAccount.DataContext = account;
                cbType.ItemsSource = idnamebll.GetByCategory("收支类型");
                //cbType.SelectedIndex = 0;
            }
            //编辑
            else
            {
                //拿出要编辑的对象的值
                account = new AccountBLL().GetById(EditingId);
                gridEditAccount.DataContext = account;
                cbType.ItemsSource = idnamebll.GetByCategory("收支类型");

            }
        }
예제 #4
0
 //搜索帐本信息
 public Account[] Search(string sql, SqlParameter[] parameters)
 {
     DataTable table = SqlHelper.ExecuteDataTable(sql, parameters);
     Account[] acc = new Account[table.Rows.Count];
     for (int i = 0; i < table.Rows.Count; i++)
     {
         acc[i] = ToAccount(table.Rows[i]);
     }
     return acc;
 }
예제 #5
0
 //赋值给Account属性值
 private Account ToAccount(DataRow row)
 {
     Account account = new Account();
     account.Id = (Guid)row["Id"];
     account.OperatorId = (Guid)row["OperatorId"];
     account.Item = (Guid)row["Item"];
     account.Money = (double)row["Money"];
     account.CostType = (Guid)row["CostType"];
     account.Date = (DateTime)row["Date"];
     account.Remarks = (string)row["Remarks"];
     return account;
 }
예제 #6
0
 //修改编辑
 public bool Update(Account account)
 {
     string sql = "UPDATE T_Account SET OperatorId=@OperatorId,Item=@Item,Money=@Money,CostType=@CostType,Date=@Date,Remarks=@Remarks WHERE Id=@Id";
     int rows = SqlHelper.ExecuteNonQuery(sql
         , new SqlParameter("@Id", account.Id)
         , new SqlParameter("@OperatorId", account.OperatorId)
         , new SqlParameter("@Item", account.Item)
         , new SqlParameter("@Money", account.Money)
         , new SqlParameter("@CostType", account.CostType)
         , new SqlParameter("@Date", account.Date)
         , new SqlParameter("@Remarks", account.Remarks)
     );
     return rows > 0;
 }
예제 #7
0
 //更新
 public bool Update(Account model)
 {
     return new AccountDAL().Update(model);
 }
예제 #8
0
 public int AddNew(Account model)
 {
     return new AccountDAL().Insert(model);
 }