///得到结账记录
        /// </summary>
        /// <param name="AccountID">结账号</param>
        /// <returns></returns>
        public ZY_Account GetAccount(int AccountID)
        {
            ZY_Account zyAccount = BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).GetModel(AccountID);

            zyAccount.AccountName = BaseNameFactory.GetName(baseNameType.用户名称, zyAccount.AccountCode);//HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetUserName(zyAccount.AccountCode);
            return(zyAccount);
        }
        /// <summary>
        /// 交款
        /// </summary>
        /// <param name="type">交款类型(1预交金,2结算费用,3全部)</param>
        /// <param name="empID">交款人ID</param>
        /// <returns></returns>
        public int[] SaveAccount(int type, string empID)
        {
            try
            {
                int[] AccountsID = new int[2];
                AccountsID[0] = -1;
                AccountsID[1] = -1;

                oleDb.BeginTransaction();


                IchargeListDao icLD = DaoFactory.GetObject <IchargeListDao>(typeof(ChargeListDao));
                IcostDao       icD  = DaoFactory.GetObject <IcostDao>(typeof(CostDao));
                icLD.oleDb = oleDb;
                icD.oleDb  = oleDb;

                if (type == 1)
                {
                    ZY_Account zyAccount = new ZY_Account();
                    zyAccount.AccountType = 0;//预交金
                    zyAccount.AccountCode = empID;
                    zyAccount.LastDate    = GetLastTime();
                    DataTable dt = GetAllCharge(empID);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["typename"].ToString() == "正常")
                        {
                            zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                        else if (dt.Rows[i]["typename"].ToString() == "退费")
                        {
                            zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                    }
                    decimal[] dec = GetMenoyAndPosFee(empID, type);
                    zyAccount.Total_Fee   = dec[0] + dec[1];
                    zyAccount.Cash_Fee    = dec[0];
                    zyAccount.POS_Fee     = dec[1];
                    zyAccount.AccountCode = empID;
                    zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                    BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount);

                    AccountsID[0] = zyAccount.AccountID;
                    icLD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID);
                }
                else if (type == 2)
                {
                    ZY_Account zyAccount = new ZY_Account();
                    zyAccount.AccountType = 1;//结算
                    zyAccount.AccountCode = empID;
                    zyAccount.LastDate    = GetLastTime();
                    DataTable dt = GetAllCost(empID);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["typename"].ToString() == "结补")
                        {
                            zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                        else if (dt.Rows[i]["typename"].ToString() == "结退")
                        {
                            zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                    }
                    decimal[] dec = GetMenoyAndPosFee(empID, type);
                    zyAccount.Total_Fee   = dec[0] + dec[1];
                    zyAccount.Cash_Fee    = dec[0];
                    zyAccount.POS_Fee     = dec[1];
                    zyAccount.AccountCode = empID;
                    zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                    zyAccount.CostFee     = dec[2];
                    zyAccount.FaoverFee   = dec[3];
                    BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount);

                    AccountsID[1] = zyAccount.AccountID;
                    icD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID);
                }
                else
                {
                    ZY_Account zyAccount = new ZY_Account();
                    zyAccount.AccountType = 0;//预交金
                    zyAccount.AccountCode = empID;
                    zyAccount.LastDate    = GetLastTime();
                    DataTable dt = GetAllCharge(empID);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["typename"].ToString() == "正常")
                        {
                            zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                        else if (dt.Rows[i]["typename"].ToString() == "退费")
                        {
                            zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                    }
                    decimal[] dec = GetMenoyAndPosFee(empID, 1);
                    zyAccount.Total_Fee   = dec[0] + dec[1];
                    zyAccount.Cash_Fee    = dec[0];
                    zyAccount.POS_Fee     = dec[1];
                    zyAccount.AccountCode = empID;
                    zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                    BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount);

                    AccountsID[0] = zyAccount.AccountID;
                    icLD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID);

                    zyAccount             = new ZY_Account();
                    zyAccount.AccountType = 1;//结算
                    zyAccount.AccountCode = empID;
                    zyAccount.LastDate    = GetLastTime();
                    dt = GetAllCost(empID);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["typename"].ToString() == "结补")
                        {
                            zyAccount.WTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.WTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                        else if (dt.Rows[i]["typename"].ToString() == "结退")
                        {
                            zyAccount.BTicketFee = Convert.ToDecimal(dt.Rows[i]["tol_fee"]);
                            zyAccount.BTicketNum = Convert.ToInt32(dt.Rows[i]["count"]);
                        }
                    }
                    dec = GetMenoyAndPosFee(empID, 2);
                    zyAccount.Total_Fee   = dec[0] + dec[1];
                    zyAccount.Cash_Fee    = dec[0];
                    zyAccount.POS_Fee     = dec[1];
                    zyAccount.AccountCode = empID;
                    zyAccount.AccountDate = HIS.SYSTEM.PubicBaseClasses.XcDate.ServerDateTime;
                    zyAccount.CostFee     = dec[2];
                    zyAccount.FaoverFee   = dec[3];
                    BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).Add(zyAccount);

                    AccountsID[1] = zyAccount.AccountID;
                    icD.UpdateAccount(zyAccount.AccountCode, zyAccount.AccountID);
                }
                //oleDb.StoreProcedureName = "";
                //oleDb.Coding = "";
                oleDb.CommitTransaction();
                return(AccountsID);
            }
            catch (System.Exception e)
            {
                oleDb.RollbackTransaction();
                throw new Exception(e.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到病人的全部预交金
        /// </summary>
        /// <returns></returns>
        public DataTable GetPatChargeList()
        {
            try
            {
                //Dal.ZY_DAL zy_ChargeList = new HIS.DAL.ZY_DAL();
                //zy_ChargeList._OleDB = oleDb;
                string str = "PATLISTID =" + this.PatListID;
                List <ZY_ChargeList> zyChargeList = BindEntity <ZY_ChargeList> .CreateInstanceDAL(oleDb).GetListArray(str);

                //List<ZY_ChargeList_Son> zyChargeListSon = new List<ZY_ChargeList_Son>();


                for (int i = 0; i < zyChargeList.Count; i++)
                {
                    // ZY_ChargeList_Son _zyChargeSon = new ZY_ChargeList_Son();
                    // _zyChargeSon = (ZY_ChargeList_Son)HIS.SYSTEM.PubicBaseClasses.ApiFunction.ObjectToObj(zyChargeList[i], _zyChargeSon);
                    if (zyChargeList[i].FeeType == 0)
                    {
                        zyChargeList[i].ChargeType = "现金";
                    }
                    else if (zyChargeList[i].FeeType == 1)
                    {
                        zyChargeList[i].ChargeType = "POS";
                    }

                    if (zyChargeList[i].Record_Flag == 0)
                    {
                        if (zyChargeList[i].Delete_Flag == 0)
                        {
                            zyChargeList[i].DelType = "正常";
                        }
                        else
                        {
                            zyChargeList[i].DelType = "正常  【已结算】";
                        }
                    }
                    else if (zyChargeList[i].Record_Flag == 1)
                    {
                        if (zyChargeList[i].Total_Fee < 0)
                        {
                            if (zyChargeList[i].Delete_Flag == 0)
                            {
                                zyChargeList[i].DelType = "作废";
                            }
                            else
                            {
                                zyChargeList[i].DelType = "作废  【已结算】";
                            }
                        }
                        else
                        {
                            if (zyChargeList[i].Delete_Flag == 0)
                            {
                                zyChargeList[i].DelType = "被作废";
                            }
                            else
                            {
                                zyChargeList[i].DelType = "被作废【已结算】";
                            }
                        }
                    }
                    else if (zyChargeList[i].Record_Flag == 2)
                    {
                        if (zyChargeList[i].Total_Fee < 0)
                        {
                            if (zyChargeList[i].Delete_Flag == 0)
                            {
                                zyChargeList[i].DelType = "退费";
                            }
                            else
                            {
                                zyChargeList[i].DelType = "退费  【已结算】";
                            }
                        }
                        else
                        {
                            if (zyChargeList[i].Delete_Flag == 0)
                            {
                                zyChargeList[i].DelType = "被退费";
                            }
                            else
                            {
                                zyChargeList[i].DelType = "被退费【已结算】";
                            }
                        }
                    }
                    //else if (zyChargeList[i].Record_Flag == 3)
                    //{
                    //    zyChargeList[i].DelType = "中结";
                    //}
                    zyChargeList[i].ChargeUserName = BaseNameFactory.GetName(baseNameType.用户名称, zyChargeList[i].ChargeCode);//HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetUserName(zyChargeList[i].ChargeCode);//? //(new GWMHIS.BussinessLogicLayer.Classes.User(Convert.ToInt64(zyChargeList[i].ChargeCode))).Name;

                    if (zyChargeList[i].AccountID == 0)
                    {
                        zyChargeList[i].AccountUserName = "";
                    }
                    else
                    {
                        ZY_Account zyAccount = BindEntity <ZY_Account> .CreateInstanceDAL(oleDb).GetModel(zyChargeList[i].AccountID);

                        //zyChargeList[i].AccountUserName = //HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetUserName(zyAccount.AccountCode);
                        zyChargeList[i].AccountUserName = BaseNameFactory.GetName(baseNameType.用户名称, zyAccount.AccountCode);//HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.GetUserName(zyAccount.AccountCode);
                        zyChargeList[i].AccountDate     = zyAccount.AccountDate;
                    }
                    //zyChargeListSon.Add(_zyChargeSon);
                }
                return(HIS.SYSTEM.PubicBaseClasses.ApiFunction.ObjToDataTable(zyChargeList));
            }
            catch (System.Exception e)
            {
                throw new Exception(e.Message);
            }
        }