public Baccount CreateBaccount(Baccount info)
 {
     try
     {
         Management.BeginTransaction();
         Management.CreateBaccount(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }
        protected void ReadEntityToControl(Baccount baccountinfo)
        {
            lblAssetNo.Text = baccountinfo.Assetno;
            if (baccountinfo.Createddate.HasValue)
            {

                litApplydate.Text = Convert.ToDateTime(baccountinfo.Createddate.Value).ToString("yyyy-MM-dd"); ;
            }
            if (baccountinfo.Accounteddate.HasValue)
            {
                lblAccountDate.Text = Convert.ToDateTime(baccountinfo.Accounteddate).ToString("yyyy-MM-dd");
            }
            lblAssetName.Text = baccountinfo.Assetname;
            litApplyuser.Text = baccountinfo.Accounteduser;
            litCreateduser.Text = baccountinfo.Createduser;
        }
        public Baccount CreateBaccount(Baccount info)
        {
            try
            {
                string sqlCommand = @"INSERT INTO ""BACCOUNT"" (""ASSETNO"",""ASSETNAME"",""ACCOUNTEDDATE"",""ACCOUNTEDUSER"",""CREATEDDATE"",""CREATEDUSER"") VALUES (:Assetno,:Assetname,:Accounteddate,:Accounteduser,:Createddate,:Createduser)";
                this.Database.AddInParameter(":Assetno", info.Assetno);//DBType:VARCHAR2
                this.Database.AddInParameter(":Assetname", info.Assetname);//DBType:NVARCHAR2
                this.Database.AddInParameter(":Accounteddate", info.Accounteddate);//DBType:DATE
                this.Database.AddInParameter(":Accounteduser", info.Accounteduser);//DBType:VARCHAR2
                this.Database.AddInParameter(":Createddate", info.Createddate);//DBType:DATE
                this.Database.AddInParameter(":Createduser", info.Createduser);//DBType:VARCHAR2
                this.Database.ExecuteNonQuery(sqlCommand);

            }
            finally
            {
                this.Database.ClearParameter();
            }
            return info;
        }
 public Baccount UpdateBaccountByAssetno(Baccount info)
 {
     try
     {
         Management.BeginTransaction();
         Management.UpdateBaccountByAssetno(info);
         Management.Commit();
     }
     catch
     {
         Management.Rollback();
         throw;
     }
     return info;
 }
 public Baccount UpdateBaccountByAssetno(Baccount info)
 {
     try
     {
         this.Database.AddInParameter(":Assetno", info.Assetno);//DBType:VARCHAR2
         this.Database.AddInParameter(":Assetname", info.Assetname);//DBType:NVARCHAR2
         this.Database.AddInParameter(":Accounteddate", info.Accounteddate);//DBType:DATE
         this.Database.AddInParameter(":Accounteduser", info.Accounteduser);//DBType:VARCHAR2
         this.Database.AddInParameter(":Createddate", info.Createddate);//DBType:DATE
         this.Database.AddInParameter(":Createduser", info.Createduser);//DBType:VARCHAR2
         string sqlCommand = @"UPDATE ""BACCOUNT"" SET  ""ASSETNAME""=:Assetname , ""ACCOUNTEDDATE""=:Accounteddate , ""ACCOUNTEDUSER""=:Accounteduser , ""CREATEDDATE""=:Createddate , ""CREATEDUSER""=:Createduser WHERE  ""ASSETNO""=:Assetno";
         this.Database.ExecuteNonQuery(sqlCommand);
     }
     finally
     {
         this.Database.ClearParameter();
     }
     return info;
 }
 /// <summary>
 /// 进入B账
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnB_Account_Click(object sender, EventArgs e)
 {
     CheckSelectedAssetId();
     if(AssetIds.Count==0)
     {
         UIHelper.Alert(this, "请选择要转入B账的设备!");
         return;
     }
     var assetInfos = AssetService.RetrieveAssetByAssetno(AssetIds);
     //var noBAccountAssetInfos = assetInfos.Where(p => p.Financecategory != FinanceCategory.BAccount).ToList();
     var bAccountInfos = BaccountService.RetrieveBaccountByAssetno(AssetIds);
     bool isAllB = true;
     foreach (var assetInfo in assetInfos)
     {
         var existInfo = bAccountInfos.Where(p => p.Assetno == assetInfo.Assetno).FirstOrDefault();
         if(existInfo==null)
         {
             isAllB = false;
             var bAccount = new Baccount();
             bAccount.Assetno = assetInfo.Assetno;//设备编号
             bAccount.Assetname = assetInfo.Assetname;//设备名称(冗余字段)
             bAccount.Accounteddate = DateTime.Now;//入账日期
             bAccount.Accounteduser = WebContext.Current.CurrentUser.Username; //入账人
             bAccount.Createddate = DateTime.Now;//操作时间
             bAccount.Createduser = WebContext.Current.CurrentUser.Username; ;//操作人
             assetInfo.Financecategory = FinanceCategory.BAccount;
             AssetService.UpdateAssetByAssetno(assetInfo);
             BaccountService.CreateBaccount(bAccount);
         }
         else
         {
             if (assetInfo.Financecategory == FinanceCategory.AAccount)
             {
                 assetInfo.Financecategory = FinanceCategory.BAccount;
                 AssetService.UpdateAssetByAssetno(assetInfo);
             }
         }
     }
     if (isAllB)
     {
         UIHelper.Alert(this, "对不起,您选择的设备已进入B账!");
         return;
     }
     else
     {
         UIHelper.Alert(this, "转入B账成功");
     }
     LoadData(pcData.CurrentIndex);
 }