Ejemplo n.º 1
0
        /// <summary>
        /// 重打发票
        /// </summary>
        /// <param name="CostMasterID">结算ID</param>
        /// <param name="TicketNO">发票号</param>
        /// <param name="CostCode">结算人代码</param>
        /// <param name="CostDate">结算日期</param>
        /// <returns></returns>
        public int Again_Ticket(int CostMasterID, string TicketNO, string CostCode, DateTime CostDate)
        {
            IcostDao icD = DaoFactory.GetObject <IcostDao>(typeof(CostDao));

            icD.oleDb = oleDb;
            IpresDao ipD = DaoFactory.GetObject <IpresDao>(typeof(PresDao));

            ipD.oleDb = oleDb;

            try
            {
                oleDb.BeginTransaction();

                ZY_CostMaster zyCostM = BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).GetModel(CostMasterID);

                ZY_CostMaster zyCostMM = new ZY_CostMaster();
                //1Copy
                zyCostMM = (ZY_CostMaster)zyCostM.Clone();

                //zy_CostM.Update(zyCostM.CostMasterID, 1);
                string strwhere   = "COSTMASTERID =" + CostMasterID;
                string fieldvalue = "RECORD_FLAG = 1";
                BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Update(strwhere, fieldvalue);

                //3add冲帐记录
                zyCostM.Total_Fee    = 0 - zyCostM.Total_Fee;
                zyCostM.Deptosit_Fee = 0 - zyCostM.Deptosit_Fee;
                zyCostM.Self_Fee     = 0 - zyCostM.Self_Fee;
                zyCostM.Village_Fee  = 0 - zyCostM.Village_Fee;
                zyCostM.Village_Fee  = 0 - zyCostM.Village_Fee;
                zyCostM.Reality_Fee  = 0 - zyCostM.Reality_Fee;
                zyCostM.Pos_Fee      = 0 - zyCostM.Pos_Fee;
                zyCostM.Money_Fee    = 0 - zyCostM.Money_Fee;
                zyCostM.Record_Flag  = 2;
                zyCostM.OldID        = zyCostM.CostMasterID;
                zyCostM.AccountID    = 0;//add zenghao

                //zy_CostM.Add(zyCostM);
                BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Add(zyCostM);

                //4add新的重打记录
                zyCostMM.TicketNum  = GetNewTicketNO(CostDate);
                zyCostMM.TicketCode = TicketNO;
                zyCostMM.ChargeCode = CostCode;
                zyCostMM.CostDate   = CostDate;
                zyCostMM.AccountID  = 0;//add zenghao
                BindEntity <ZY_CostMaster> .CreateInstanceDAL(oleDb).Add(zyCostMM);

                //更改处方结算标志
                ipD.AlterCostID(CostMasterID, zyCostMM.CostMasterID);

                //5update 结算汇总记录

                icD.UpdateCostMID(CostMasterID, zyCostMM.CostMasterID);

                oleDb.CommitTransaction();
                return(zyCostMM.CostMasterID);
            }
            catch (System.Exception e)
            {
                oleDb.RollbackTransaction();
                return(0);

                throw new Exception(e.Message);
            }
        }