Exemple #1
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public string SaveForm(string keyValue, FixReportEntity entity)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);
                return(this.BaseRepository().Update(entity).ToString());
            }
            else
            {
                OtherincomeService dal = new OtherincomeService();
                entity.FixReportID = entity.propertyid + dal.GetMaxID(8, "wy_FixReport", "FixReportID", 8);
                if (string.IsNullOrEmpty(entity.fixNumber_No))
                {
                    entity.fixNumber_No = DateTime.Now.ToString("yyyyMMdd") + dal.GetMaxID(3, "wy_FixReport WHERE CONVERT(VARCHAR(10),ReportDate,120)=CONVERT(VARCHAR(10),GETDATE(),120)", "fixNumber_No", 3);
                }
                //entity.Create(); GetMaxID
                this.BaseRepository().Insert(entity);

                return(entity.FixReportID);
            }
        }
Exemple #2
0
        /// <summary>
        /// 修改材料
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="entitylist"></param>
        public void SavesForm(FixReportEntity entity, List <FixmaterialEntity> entitylist)
        {
            OtherincomeService dal = new OtherincomeService();
            int maxid  = dal.GetMaxID(0, "wy_fix_material", "pkeyid", 8).ToInt();
            var strSql = new StringBuilder();

            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                db.Update(entity);
                if (entitylist != null)
                {
                    foreach (FixmaterialEntity item in entitylist)
                    {
                        ////修改库存
                        if (string.IsNullOrEmpty(item.pkeyid))
                        {
                            item.fixreportid = entity.FixReportID;
                            item.pkeyid      = entity.propertyid + Utils.SupplementZero(maxid.ToString(), 8);
                            db.Insert(item);

                            maxid++;
                        }
                        else
                        {
                        }
                    }
                }

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// 获取报修单号
        /// </summary>
        /// <returns></returns>
        public string fixNumber_No()
        {
            OtherincomeService dal = new OtherincomeService();

            return(DateTime.Now.ToString("yyyyMMdd") + dal.GetMaxID(3, "wy_FixReport WHERE CONVERT(VARCHAR(10),ReportDate,120)=CONVERT(VARCHAR(10),GETDATE(),120)", "fixNumber_No", 3));
        }
Exemple #4
0
        /// <summary>
        /// 获取费用明细
        /// </summary>
        /// <param name="keyVaule"></param>
        /// <returns></returns>
        public CostInfoEntity GetCostByTicketId(string keyVaule)
        {
            FeereceiveEntity  income         = new FeereceiveService().GetEntityByTicket(keyVaule);
            bool              is_income      = false;
            OtherincomeEntity otherIncome    = new OtherincomeService().GetEntityByTicket(keyVaule);
            bool              is_otherIncome = false;

            StringBuilder builder = new StringBuilder();

            if (income != null)
            {
                is_income = true;

                #region 应收

                builder.Append(@"SELECT  receive_id ,
                                    property_id ,
                                    ( SELECT    owner_name
                                      FROM      wy_owner
                                      WHERE     owner_id = wy_feereceive.owner_id
                                    ) AS ownername ,
                                    ( SELECT TOP 1
                                                customername
                                      FROM      wy_rentcontract
                                      WHERE     contractid = wy_feereceive.rentcontract_id
                                    ) AS customername ,
                                    ( ( SELECT TOP 1
                                                building_name
                                        FROM    wy_building
                                        WHERE   building_id = ( SELECT TOP 1
                                                                        building_id
                                                                FROM    wy_room
                                                                WHERE   room_id = wy_feereceive.room_id
                                                              )
                                      ) + '/' + ( SELECT TOP 1
                                                            room_name
                                                  FROM      wy_room
                                                  WHERE     room_id = wy_feereceive.room_id
                                                ) ) AS propertyname ,
                                    receive_date ,
                                    fee_money ,
                                    ( SELECT TOP 1
                                                ticket_code
                                      FROM      wy_feeticket
                                      WHERE     ticket_id = wy_feereceive.ticket_id
                                    ) AS ticket_code ,
                                    pay_mode
                            FROM    wy_feereceive
                            WHERE   ticket_id = @ticketid");

                #endregion
            }
            else if (otherIncome != null)
            {
                is_otherIncome = true;

                #region 其他收入

                builder.Append(@"SELECT  customer AS ownername ,
                                        feedate AS receive_date ,
                                        property_id ,
                                        feemoney AS fee_money ,
                                        currency AS pay_mode ,
                                        '' AS propertyname ,
                                        incomeid ,
                                        ( SELECT TOP 1
                                                    ticket_code
                                          FROM      wy_feeticket
                                          WHERE     ticket_id = wy_otherincome.ticketid
                                        ) AS ticket_code
                                FROM    wy_otherincome
                                WHERE   ticketid = @ticketid ");

                #endregion
            }
            else
            {
                throw new Exception("发票编号不存在");
            }

            DbParameter[] parameter =
            {
                DbParameters.CreateDbParameter("@ticketid", keyVaule)
            };

            DataTable dtCost = new RepositoryFactory().BaseRepository().FindTable(builder.ToString(), parameter);
            if (dtCost != null && dtCost.Rows.Count > 0)
            {
                CostInfoEntity model = DataHelper.CreateItem <CostInfoEntity>(dtCost.Rows[0]);
                model.is_income      = is_income;
                model.is_otherIncome = is_otherIncome;

                PropertyEntity proinfo = new PropertyService().GetEntity(model.property_id);
                if (proinfo != null)
                {
                    model.property_name = proinfo.property_name;
                }

                return(model);
            }
            return(null);
        }