public frmChangePassword(Account oAccount, Account oChangePassAcc) : base(oAccount) { InitializeComponent(); ChangePassAcc = oChangePassAcc; mAccountBill = new AccountBill(mAccount); txtOldPassword.Enabled = true; }
//新增 public static void AddAccountBill(AccountBill tp) { //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory(); ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { session.Save(tp); //将数据级联更新到Companies.CurAmt Companies tC = session.Get <Companies>(tp.CompanyID); if (tp.BillType == 0) { //未收款,客户 //tC.CurAmt = tC.CurAmt + tp.BillYS - tp.BillSS; } else { //未付款,供应商 //tC.CurAmt = tC.CurAmt + tp.BillYF - tp.BillSF; } session.Save(tC); tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
//获取指定ProjectID,CompanyID,MoneyTypeID,BillMemo的AccountBill public static AccountBill GetAccountBill(int i_ProjectID, int i_CompanyID, int i_MoneyTypeID, string s_BillMemo) { DataSet ds = new DataSet(); AccountBill tR = new AccountBill(); object[] myParams = { i_ProjectID, i_CompanyID, i_MoneyTypeID, s_BillMemo }; ds = SQLiteHelper.ExecuteDataSet("SELECT BillNo,ProjectID,CompanyID,CompanyName,MoneyTypeID,BillType,BillMemo,BillYS,BillSS,BillYF,BillSF,BillDate,BillCycle,BillStatus FROM AccountBill WHERE ProjectID = @ProjectID AND CompanyID = @CompanyID AND MoneyTypeID=@MoneyType AND BillMemo = @BillMemo", myParams); foreach (DataRow mDr in ds.Tables[0].Rows) { tR.BillNo = Convert.ToInt32(mDr["BillNo"].ToString()); tR.ProjectID = Convert.ToInt32(mDr["ProjectID"].ToString()); tR.CompanyID = Convert.ToInt32(mDr["CompanyID"].ToString()); tR.CompanyName = mDr["CompanyName"].ToString(); tR.MoneyTypeID = Convert.ToInt32(mDr["MoneyTypeID"].ToString()); tR.BillType = Convert.ToInt32(mDr["BillType"].ToString()); tR.BillMemo = mDr["BillMemo"].ToString(); tR.BillYS = Convert.ToDecimal(mDr["BillYS"].ToString()); tR.BillSS = Convert.ToDecimal(mDr["BillSS"].ToString()); tR.BillYF = Convert.ToDecimal(mDr["BillYF"].ToString()); tR.BillSF = Convert.ToDecimal(mDr["BillSF"].ToString()); tR.BillDate = Convert.ToDateTime(mDr["BillDate"].ToString()); tR.BillCycle = mDr["BillCycle"].ToString(); tR.BillStatus = mDr["BillStatus"].ToString(); } return(tR); }
public frmStanUsers(Account oAccount, int UserId) : base(oAccount) //Update { InitializeComponent(); mAccountBiLL = new AccountBill(mAccount); txtPassword.Enabled = false; txtPasswordAfter.Enabled = false; DisplayAccNow(UserId); }
void ButtonSaveClick(object sender, EventArgs e) { //按照窗口标题来确定保存数据的操作 AccountBill t1 = new AccountBill(); t1.BillDate = dateTimePickerBillDate.Value; t1.BillMemo = textBoxBillMemo.Text.Trim(); t1.CompanyID = Convert.ToInt32(comboBoxComPany.SelectedValue.ToString()); t1.ProjectID = Convert.ToInt32(comboBoxProject.SelectedValue.ToString()); t1.MoneyTypeID = Convert.ToInt32(comboBoxMoneyType.SelectedValue.ToString()); switch (this.Text) { case "未收款-新增": t1.BillYS = Convert.ToDecimal(textBoxBillMoney.Text.ToString()); t1.BillSS = 0; t1.BillYF = 0; t1.BillSF = 0; t1.BillType = 0; break; case "未收款-收款": t1.BillYS = 0; t1.BillSS = Convert.ToDecimal(textBoxBillMoney.Text.ToString()); t1.BillYF = 0; t1.BillSF = 0; t1.BillType = 0; break; case "未付款-新增": t1.BillYS = 0; t1.BillSS = 0; t1.BillYF = Convert.ToDecimal(textBoxBillMoney.Text.ToString()); t1.BillSF = 0; t1.BillType = 1; break; case "未付款-付款": t1.BillYS = 0; t1.BillSS = 0; t1.BillYF = 0; t1.BillSF = Convert.ToDecimal(textBoxBillMoney.Text.ToString()); t1.BillType = 1; break; default: break; } BLL.AccountBillBLL.AddAccountBill(t1); this.Close(); }
public static void UpdateRKD(int i_ProjectID, int i_CompanyID, string s_RecordStatus, string s_BillCycle, DataGridViewSelectedRowCollection dC) { decimal dTotal = 0.0M; foreach (DataGridViewRow row in dC) { int i_ReceiptID = Convert.ToInt32(row.Cells["ReceiptID"].Value.ToString()); string s_ReceiptNum = row.Cells["ReceiptNum"].Value.ToString(); dTotal += Convert.ToDecimal(row.Cells["ReceiptDiscAmt"].Value); UpdateReceipt(i_ReceiptID, s_RecordStatus, s_BillCycle); AccountBill tAB = BLL.AccountBillBLL.GetAccountBill(i_ProjectID, i_CompanyID, 100, "采购应付款" + s_ReceiptNum); tAB.BillCycle = s_BillCycle; tAB.BillStatus = s_RecordStatus; BLL.AccountBillBLL.UpdateAccountBill(tAB); } //更新到StatementList表中。 ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { Projects tP = session.Get <Projects>(i_ProjectID); Companies tC = session.Get <Companies>(i_CompanyID); StatementList tS = new StatementList(); tS.CompanyID = i_CompanyID; tS.CompanyName = tC.CompanyName; tS.ProjectID = i_ProjectID; tS.ProjectName = tP.ProjectName; tS.BillYS = 0.0M; tS.BillSS = 0.0M; tS.BillYF = dTotal; tS.BillSF = 0.0M; tS.StatementType = "入库结算"; tS.StatementCycle = s_BillCycle; tS.MoneyTypeID = 10000; tS.MoneyTypeName = "入库结算自动生成"; tS.StatementMemo = "结算应付款"; tS.StatementDate = DateTime.Now; session.Save(tS); tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
//修改 public static void UpdateAccountBill(AccountBill tp) { ISession session = NHibernateHelper.OpenSession(); try { ITransaction tx = session.BeginTransaction(); AccountBill t1 = session.Get <AccountBill>(tp.BillNo); //将数据级联更新到Companies.CurAmt Companies tC = session.Get <Companies>(tp.CompanyID); if (tp.BillType == 0) { //未收款,客户 //tC.CurAmt = tC.CurAmt + (t1.BillYS - tp.BillYS) - (t1.BillSS - tp.BillSS); } else { //未付款,供应商 //tC.CurAmt = tC.CurAmt + (t1.BillYF - tp.BillYF) - (t1.BillSF - tp.BillSF); } session.Save(tC); t1.ProjectID = tp.ProjectID; t1.CompanyID = tp.CompanyID; t1.CompanyName = tp.CompanyName; t1.MoneyTypeID = tp.MoneyTypeID; t1.BillType = tp.BillType; t1.BillMemo = tp.BillMemo; t1.BillYS = tp.BillYS; t1.BillSS = tp.BillSS; t1.BillYF = tp.BillYF; t1.BillSF = tp.BillSF; t1.BillDate = tp.BillDate; t1.BillCycle = tp.BillCycle; t1.BillStatus = tp.BillStatus; tx.Commit(); } catch (Exception e) { Debug.Assert(false, e.Message); } session.Close(); }
public string GetEchartsData() { SearchAccountBillDto search = new SearchAccountBillDto() { UserID = Convert.ToInt32(User.FindFirstValue(ClaimTypes.Sid)), BegDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1) }; var lst = _accountBillService.GetAllBillsQuery(search).ToList(); string json = string.Empty; if (lst.Count() == 0) { AccountBill entity = new AccountBill() { AccountMoney = 0 }; lst.Add(entity); } return(JsonConvert.SerializeObject(lst, Formatting.Indented)); }
public frmStanUsers(Account oAccount) : base(oAccount) //Insert { InitializeComponent(); mAccountBiLL = new AccountBill(mAccount); }
//删除入库单 public static void DelRKD(int i_ReceiptID) { ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { Receipt toDel1 = session.Get <Receipt>(i_ReceiptID); //更新未付款 //如果原应付款不为0,则删除AccountBill表的相关数据,并更新WareHouseStock表中的相关数据 if (toDel1.ReceiptDiscAmt != 0) { AccountBill tAB = BLL.AccountBillBLL.GetAccountBill(toDel1.ProjectID, toDel1.CompanyID, 100, "采购应付款" + toDel1.ReceiptNum); if (tAB.BillNo == 0) { tx.Rollback(); session.Close(); MessageBox.Show("没有找到可以删除的入库单生成的应付款记录!请检查数据库!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AccountBill toDelete = session.Get <AccountBill>(tAB.BillNo); session.Delete(toDelete); } //删除ReceiptItem中的相关项 List <int> toDelItemsID = BLL.RKBLL.GetItemIDs(toDel1.ReceiptID); foreach (int i in toDelItemsID) { ReceiptItems toDel2 = session.Get <ReceiptItems>(i); session.Delete(toDel2); //更新库存 PKModel pk = new PKModel(); pk.GoodsID = toDel2.GoodsID; pk.WareHouseID = toDel1.WareHouseID; WareHouseStock tWH = session.Get <WareHouseStock>(pk); if (tWH != null) { tWH.Number -= toDel2.GoodsQty; tWH.Amount -= toDel2.GoodsAmt; if (tWH.Number != 0) { tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2); } else { tWH.Price = 0; } } } session.Delete(toDel1); //事务提交 tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
//修改入库单 public static void ModifyRKD(Receipt tReceipt, List <ReceiptItems> tItemsList) { //修改入库单 ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { //得到未变更的入库单 Receipt tOldReceipt = new Receipt(); tOldReceipt = BLL.RKBLL.GetReceipt(tReceipt.ReceiptID); //如果原应付款不为0,则删除AccountBill表的相关数据,并更新Companies表中的相关数据 if (tOldReceipt.ReceiptDiscAmt != 0) { AccountBill tAB = BLL.AccountBillBLL.GetAccountBill(tOldReceipt.ProjectID, tOldReceipt.CompanyID, 100, "采购应付款" + tOldReceipt.ReceiptNum); if (tAB.BillNo == 0) { tx.Rollback(); session.Close(); MessageBox.Show("没有找到可以删除的入库单生成的应付款记录!请检查数据库!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AccountBill toDelete = session.Get <AccountBill>(tAB.BillNo); session.Delete(toDelete); } //删除ReceiptItem中的相关项 List <int> toDelItemsID = BLL.RKBLL.GetItemIDs(tOldReceipt.ReceiptID); foreach (int i in toDelItemsID) { ReceiptItems toDel1 = session.Get <ReceiptItems>(i); session.Delete(toDel1); //更新库存 PKModel pk = new PKModel(); pk.GoodsID = toDel1.GoodsID; pk.WareHouseID = tOldReceipt.WareHouseID; WareHouseStock tWH = session.Get <WareHouseStock>(pk); if (tWH == null) { WareHouseStock tWHNew = new WareHouseStock(); tWHNew.Pk = pk; tWHNew.Number = toDel1.GoodsQty; tWHNew.Price = toDel1.GoodsPrc; tWHNew.Amount = toDel1.GoodsAmt; session.Save(tWHNew); } else { tWH.Number -= toDel1.GoodsQty; tWH.Amount -= toDel1.GoodsAmt; if (tWH.Number != 0) { tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2); } session.Flush(); } } //保存Receipt的修改 Receipt toModify = session.Get <Receipt>(tOldReceipt.ReceiptID); toModify.CompanyID = tReceipt.CompanyID; toModify.ProjectID = tReceipt.ProjectID; toModify.ReceiptType = tReceipt.ReceiptType; toModify.ReceiptBillAmt = tReceipt.ReceiptBillAmt; toModify.ReceiptDisc = tReceipt.ReceiptDisc; toModify.ReceiptDiscAmt = tReceipt.ReceiptDiscAmt; toModify.PurchName = tReceipt.PurchName; toModify.ReceiverName = tReceipt.ReceiverName; toModify.RecordStatus = "已记账"; toModify.Remark = tReceipt.Remark; toModify.WareHouseID = tReceipt.WareHouseID; //将新的ReceiptItem加入 foreach (ReceiptItems tRI in tItemsList) { tRI.ReceiptID = tReceipt.ReceiptID; session.Save(tRI); //更新库存 PKModel pk = new PKModel(); pk.GoodsID = tRI.GoodsID; pk.WareHouseID = tReceipt.WareHouseID; WareHouseStock tWH = session.Get <WareHouseStock>(pk); if (tWH == null) { WareHouseStock tWHNew = new WareHouseStock(); tWHNew.Pk = pk; tWHNew.Number = tRI.GoodsQty; tWHNew.Price = tRI.GoodsPrc; tWHNew.Amount = tRI.GoodsAmt; session.Save(tWHNew); } else { tWH.Number += tRI.GoodsQty; tWH.Amount += tRI.GoodsAmt; if (tWH.Number != 0) { tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2); } session.Flush(); } } //根据应付款是否为0添加AccountBill记录及更新Companies表 if (tReceipt.ReceiptDiscAmt != 0) { Projects tP1 = session.Get <Projects>(tReceipt.ProjectID); Companies tC1 = session.Get <Companies>(tReceipt.CompanyID); AccountBill tAcc = new AccountBill(); tAcc.CompanyID = tReceipt.CompanyID; tAcc.CompanyName = tC1.CompanyName; tAcc.BillDate = tReceipt.ReceiptDate; tAcc.BillMemo = "采购应付款" + tReceipt.ReceiptNum; tAcc.BillType = 1; tAcc.BillYF = tReceipt.ReceiptDiscAmt; tAcc.ProjectID = tReceipt.ProjectID; tAcc.ProjectName = tP1.ProjectName; tAcc.MoneyTypeID = 100; //材料购买 tAcc.MoneyTypeName = "入库单生成"; tAcc.BillStatus = "已记账"; session.Save(tAcc); } //事务提交 tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
//增加入库单 public static void AddRKD(Receipt tReceipt, List <ReceiptItems> tItemsList) { //保存数据,注意使用事务进行处理 //1、入库单号的生成与修改;2、入库单的增加;3入库单项目的增加 ISession session = NHibernateHelper.sessionFactory.OpenSession(); ITransaction tx = session.BeginTransaction(); try { //查最后的入库单号 IList <ProgOptions> Key1 = BLL.ProgOptionsBLL.GetOptions("RKD_LastNumber"); string s_RKD_LastNo = Key1[0].OptionsValue; string s_RKD_NewNo; string s_RKD_LastYM; string s_RKD_NewYM; int LastNo; int NewNo; string s_NewNo; s_RKD_NewYM = DateTime.Today.ToString("yyyyMM"); if (s_RKD_LastNo.Length == 10) { //4位年+2位月+4位顺序号 s_RKD_LastYM = s_RKD_LastNo.Substring(0, 6); LastNo = Convert.ToInt32(s_RKD_LastNo.Substring(6, 4)); if (s_RKD_NewYM != s_RKD_LastYM) { NewNo = 1; } else { NewNo = LastNo + 1; } } else { //没有数据 NewNo = 1; } s_NewNo = "0000" + NewNo.ToString(); s_NewNo = s_NewNo.Substring(s_NewNo.Length - 4, 4); //将新的最后编号保存到数据库 ProgOptions t1 = session.Get <ProgOptions>(Key1[0].OptionsID); t1.OptionsID = Key1[0].OptionsID; t1.OptionsKey = Key1[0].OptionsKey; s_RKD_NewNo = s_RKD_NewYM + s_NewNo; t1.OptionsValue = s_RKD_NewNo; t1.OptionsRemark = Key1[0].OptionsRemark; //保存入库单 tReceipt.ReceiptNum = "RKD-" + t1.OptionsValue; session.Save(tReceipt); //添加应付款 if (tReceipt.ReceiptDiscAmt != 0) { Projects tP1 = session.Get <Projects>(tReceipt.ProjectID); Companies tC1 = session.Get <Companies>(tReceipt.CompanyID); AccountBill tAcc = new AccountBill(); tAcc.CompanyID = tReceipt.CompanyID; tAcc.CompanyName = tC1.CompanyName; tAcc.BillDate = tReceipt.ReceiptDate; tAcc.BillMemo = "采购应付款" + tReceipt.ReceiptNum; tAcc.BillType = 1; tAcc.BillYF = tReceipt.ReceiptDiscAmt; tAcc.ProjectID = tReceipt.ProjectID; tAcc.ProjectName = tP1.ProjectName; tAcc.MoneyTypeID = 100; //材料购买 tAcc.MoneyTypeName = "入库单生成"; tAcc.BillStatus = "已记账"; session.Save(tAcc); } foreach (ReceiptItems tRI in tItemsList) { //保存进货项 ReceiptItems tNewReceiptItems = new ReceiptItems(); tNewReceiptItems.GoodsID = tRI.GoodsID; tNewReceiptItems.ReceiptID = tReceipt.ReceiptID; tNewReceiptItems.GoodsName = tRI.GoodsName; tNewReceiptItems.GoodsAmt = tRI.GoodsAmt; tNewReceiptItems.GoodsPlan = tRI.GoodsPlan; tNewReceiptItems.GoodsPlanNo = tRI.GoodsPlanNo; tNewReceiptItems.GoodsPrc = tRI.GoodsPrc; tNewReceiptItems.GoodsQty = tRI.GoodsQty; tNewReceiptItems.GoodsSpec = tRI.GoodsSpec; tNewReceiptItems.GoodsUnit = tRI.GoodsUnit; tNewReceiptItems.GoodsYF = tRI.GoodsYF; tNewReceiptItems.GoodsTaxRate = tRI.GoodsTaxRate; tNewReceiptItems.GoodsNoTaxPrice = tRI.GoodsNoTaxPrice; tNewReceiptItems.MoreSpec = tRI.MoreSpec; tNewReceiptItems.UsePosition = tRI.UsePosition; session.Save(tNewReceiptItems); } //入库单同货品合并 List <ReceiptItems> mergeList = new List <ReceiptItems>(); foreach (ReceiptItems tRI in tItemsList) { ReceiptItems rtnRItem = mergeList.Find(name => { if (name.GoodsID == tRI.GoodsID) { return(true); } else { return(false); } }); if (rtnRItem == null) { mergeList.Add(tRI); } else { rtnRItem.GoodsQty += tRI.GoodsQty; rtnRItem.GoodsAmt += tRI.GoodsAmt; if (rtnRItem.GoodsQty != 0) { rtnRItem.GoodsPrc = rtnRItem.GoodsAmt / rtnRItem.GoodsQty; } } } //更新库存 foreach (ReceiptItems tRI in mergeList) { PKModel pk = new PKModel(); pk.GoodsID = tRI.GoodsID; pk.WareHouseID = tReceipt.WareHouseID; WareHouseStock tWH = session.Get <WareHouseStock>(pk); if (tWH == null) { WareHouseStock tWHNew = new WareHouseStock(); tWHNew.Pk = pk; tWHNew.Number = tRI.GoodsQty; tWHNew.LastPrice = tRI.GoodsPrc; tWHNew.Price = tRI.GoodsPrc; tWHNew.Amount = tRI.GoodsAmt; session.Save(tWHNew); } else { tWH.Number += tRI.GoodsQty; tWH.Amount += tRI.GoodsAmt; tWH.LastPrice = tRI.GoodsPrc; if (tWH.Number != 0) { tWH.Price = Math.Round(tWH.Amount / tWH.Number, 2); } session.Flush(); } } //事务提交 tx.Commit(); session.Close(); } catch (Exception e) { Debug.Assert(false, e.Message); tx.Rollback(); session.Close(); } }
private void uQuanLyUser_Load(object sender, EventArgs e) { actionUpdate1.PressUpdate += new EventHandler(ActionUpdate1_PressUpdate); actionUpdate1.PressNew += new EventHandler(ActionUpdate1_PressNew); actionUpdate1.PressHelp += new EventHandler(ActionUpdate1_PressHelp); actionUpdate1.PressClose += new EventHandler(ActionUpdate1_PressClose); List <Account> lstAcc = new List <Account>(); lstAcc = new AccountBill(mAccount).getElements(); //TreeNode user = new TreeNode(); //treeView1.Nodes.Add(user); //user.Text = "User"; //List<TreeNode> lstTreeUser = new List<TreeNode>(); TreeNode adminNode = new TreeNode("Admin"); TreeNode userNode = new TreeNode("User"); if (mAccount.IsSuperUser == true) { treeView1.Nodes.Add(adminNode); treeView1.Nodes.Add(userNode); } else { if (mAccount.isAdmin == 1) { treeView1.Nodes.Add(userNode); } } foreach (Account item in lstAcc) { //if(item.IsSuperUser == false) //{ // TreeNode node = new TreeNode(); // node.Tag = item; // node.Text = item.DisplayName; // user.Nodes.Add(node); //} if (item.isAdmin == 1) // Admin { TreeNode node = new TreeNode(item.DisplayName); node.Tag = item; adminNode.Nodes.Add(node); } else if (item.isAdmin == 0) // User { TreeNode node = new TreeNode(item.DisplayName); node.Tag = item; userNode.Nodes.Add(node); } } if (mNewId != 0) { DisplayOfNewAccount(); } this.Dock = DockStyle.Fill; if (mAccount.isAdmin == 0) { this.Controls.Clear(); } }
public frmLogin(Account oAccount) : base(oAccount) { InitializeComponent(); mAccountBill = new AccountBill(mAccount); }
public uListUsers(Account oAccount) { InitializeComponent(); mAccount = oAccount; mAccountBiLL = new AccountBill(mAccount); }