Example #1
0
        //更新房态基本信息表
        public static void UpdateHotelStatus(EnumDef.EHRoomStatusType tnUpdateStyle, int tnUpdateNum, DateTime tsUpdateDate, String tsHBaseInfoId, int tnEmployeeID)
        {
            String lsSQL        = "SELECT * FROM HOTELSTATUS WHERE HOTELINFOID = " + tsHBaseInfoId.Trim() + " AND USEDATE = to_date('" + tsUpdateDate + "','yyyy-mm-dd hh24:mi:ss')";
            int    lnRoomBuyNum = 0;
            int    lnRoomHold   = 0;

            DataSet ds      = new DataSet();
            String  lsError = "";

            if (DBA.SelectSQL("", lsSQL, ref ds, ref lsError) > 0)
            {
                switch (tnUpdateStyle)
                {
                case EnumDef.EHRoomStatusType.买房:
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        lnRoomBuyNum += IntUtil.SafeCInt(ds.Tables[0].Rows[0]["BUYHOUSENUM"]) + tnUpdateNum;
                    }

                    break;

                case EnumDef.EHRoomStatusType.占房:
                    break;

                case EnumDef.EHRoomStatusType.预留房:
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        lnRoomHold += IntUtil.SafeCInt(ds.Tables[0].Rows[0]["OBLIGATEHOUSENUM"]) + tnUpdateNum;
                    }
                    break;

                case EnumDef.EHRoomStatusType.满房:
                    break;
                }



                String lsSQLUpdate = @"update HOTELSTATUS set  BuyHouseNum = :BuyHouseNum,OBLIGATEHOUSENUM = :OBLIGATEHOUSENUM
                                        where HOUSESTATETYPEID = :HOUSESTATETYPEID ";

                OracleConnection loOraConn = DBA.GetOraConnection("CRMDB");
                try
                {
                    OracleCommand loOraComm = new OracleCommand(lsSQLUpdate, loOraConn);

                    DBUtil.AddParameter(loOraComm, "BuyHouseNum", lnRoomBuyNum);
                    DBUtil.AddParameter(loOraComm, "OBLIGATEHOUSENUM", lnRoomHold);
                    DBUtil.AddParameter(loOraComm, "HOUSESTATETYPEID", IntUtil.SafeCInt(ds.Tables[0].Rows[0]["HOUSESTATETYPEID"]));

                    loOraComm.ExecuteNonQuery();
                }
                finally
                {
                    DBA.CloseOraConnection(loOraConn);
                }
            }
            else
            {
                switch (tnUpdateStyle)
                {
                case EnumDef.EHRoomStatusType.买房:
                    lnRoomBuyNum += tnUpdateNum;

                    break;

                case EnumDef.EHRoomStatusType.占房:
                    break;

                case EnumDef.EHRoomStatusType.预留房:
                    lnRoomHold += tnUpdateNum;
                    break;

                case EnumDef.EHRoomStatusType.满房:
                    break;
                }

                String lsSQLInsert = @"insert into  HOTELSTATUS (HOUSESTATETYPEID,HOTELINFOID,USEDATE,BUYHOUSENUM,OBLIGATEHOUSENUM,OPERATETIME,EmployeeInfoID)
                                          Values(:HOUSESTATETYPEID,:HOTELINFOID,:USEDATE,:BUYHOUSENUM,:OBLIGATEHOUSENUM,:OPERATETIME,:EmployeeInfoID)";


                OracleConnection loOraConn = DBA.GetOraConnection("CRMDB");
                try
                {
                    OracleCommand loOraComm = new OracleCommand(lsSQLInsert, loOraConn);

                    DBUtil.AddParameter(loOraComm, "HOUSESTATETYPEID", IntUtil.SafeCInt(CommonDBFunction.GenerateIdentity("HOTELSTATUS")));
                    DBUtil.AddParameter(loOraComm, "HOTELINFOID", IntUtil.SafeCInt(tsHBaseInfoId));
                    DBUtil.AddParameter(loOraComm, "USEDATE", Convert.ToDateTime(tsUpdateDate));
                    DBUtil.AddParameter(loOraComm, "BUYHOUSENUM", lnRoomBuyNum);
                    DBUtil.AddParameter(loOraComm, "OBLIGATEHOUSENUM", lnRoomHold);
                    DBUtil.AddParameter(loOraComm, "OPERATETIME", DateUitl.GetDateTime());
                    DBUtil.AddParameter(loOraComm, "EmployeeInfoID", tnEmployeeID);

                    loOraComm.ExecuteNonQuery();
                }
                finally
                {
                    DBA.CloseOraConnection(loOraConn);
                }
            }
        }