public int UpdateConsumeDetail(ConsumeDetailModel mConsume, ObjectControls oCtrl) { string sql = " UPDATE CONSUME_DETAIL SET CREATE_DATE=CREATE_DATE"; oCtrl.Helper(oCtrl.Exsit(MCtrl.SetStayId) && oCtrl.Append(ref sql, ",STAY_ID=" + SQL(mConsume.StayId))); oCtrl.Helper(oCtrl.Exsit(MCtrl.SetGoodsId) && oCtrl.Append(ref sql, ",GOODS_ID=" + SQL(mConsume.GoodsId))); oCtrl.Helper(oCtrl.Exsit(MCtrl.SetNumber) && oCtrl.Append(ref sql, ",NUMBER=" + SQL(mConsume.Number))); oCtrl.Helper(oCtrl.Exsit(MCtrl.SetUnitPrice) && oCtrl.Append(ref sql, ",UNIT_PRICE=" + SQL(mConsume.UnitPrice))); oCtrl.Helper(oCtrl.Exsit(MCtrl.SetTotal) && oCtrl.Append(ref sql, ",TOTAL=" + SQL(mConsume.Total))); sql += " ,UPDATE_DATE=" + SQL(GetDBTime) + ",UPDATE_USERID=" + SQL(mConsume.CommonInfo.UpdateUserId); return(ExcuteNonQuery(sql)); }
public List <ConsumeDetailModel> GetConsumeList(ConsumeDetailModel mConsume, ObjectControls oCtrl) { string sql = @"SELECT CONSUME_ID,A.STAY_ID, A.GOODS_ID, A.CREATE_DATE, A.CREATE_USERID, A.UPDATE_DATE, A.UPDATE_USERID, A.UNIT_PRICE, A.NUMBER, A.TOTAL, B.GOODS_NAME, B.GOODS_UNIT, B.PRICE , B.TYPE, B.STATUS, D.ROOM_NO,E.USER_NAME FROM CONSUME_DETAIL AS A INNER JOIN CUSTOMER_STAY_INFO AS C ON A.STAY_ID = C.STAY_ID INNER JOIN BAS_GOODS_INFO AS B ON A.GOODS_ID = B.GOODS_ID INNER JOIN BAS_ROOM_INFO AS D ON C.ROOM_ID = D.ROOM_ID INNER JOIN SYS_USER_INFO AS E ON A.CREATE_USERID = E.USER_ID"; sql += " WHERE 1=1"; oCtrl.Helper(oCtrl.Exsit(MCtrl.ByStayIdGroup) && oCtrl.Append(ref sql, " AND A.STAY_ID IN (" + mConsume.StayIdGroup + ")")); oCtrl.Helper(oCtrl.Exsit(MCtrl.ByStayId) && oCtrl.Append(ref sql, " AND A.STAY_ID=" + mConsume.StayId)); oCtrl.Helper(oCtrl.Exsit(MCtrl.ByGoodsId) && oCtrl.Append(ref sql, " AND A.GOODS_ID=" + mConsume.GoodsId)); sql += " ORDER BY A.CREATE_DATE"; sdr = ExecuteReader(sql); List <ConsumeDetailModel> listConsumDetail = new List <ConsumeDetailModel>(); using (sdr) { while (sdr.Read()) { ConsumeDetailModel mConsumeInfo = new ConsumeDetailModel(); mConsumeInfo.ConsumeId = ToInt32(sdr["CONSUME_ID"]); mConsumeInfo.StayId = ToInt32(sdr["STAY_ID"]); mConsumeInfo.GoodsId = ToInt32(sdr["GOODS_ID"]); mConsumeInfo.CommonInfo = new CommonModel(); mConsumeInfo.CommonInfo.CreateDate = ToDateTime(sdr["CREATE_DATE"]); mConsumeInfo.CommonInfo.CreateUserId = ToInt32(sdr["CREATE_USERID"]); mConsumeInfo.CommonInfo.UpdateDate = ToDateTime(sdr["UPDATE_DATE"]); mConsumeInfo.CommonInfo.UpdateUserId = ToInt32(sdr["UPDATE_USERID"]); mConsumeInfo.UnitPrice = ToDouble(sdr["UNIT_PRICE"]); mConsumeInfo.Number = ToDouble(sdr["NUMBER"]); mConsumeInfo.Total = ToDouble(sdr["TOTAL"]); mConsumeInfo.GoodsInfo = new BasGoodsModel(); mConsumeInfo.GoodsInfo.GoodsName = ToString(sdr["GOODS_NAME"]); mConsumeInfo.GoodsInfo.GoodsUnit = ToString(sdr["GOODS_UNIT"]); mConsumeInfo.GoodsInfo.Price = ToDouble(sdr["PRICE"]); mConsumeInfo.GoodsInfo.Type = ToChar(sdr["TYPE"]); mConsumeInfo.GoodsInfo.Status = ToChar(sdr["STATUS"]); mConsumeInfo.RoomNo = ToString(sdr["ROOM_NO"]); mConsumeInfo.CommonInfo.CreateUserName = ToString(sdr["USER_NAME"]); listConsumDetail.Add(mConsumeInfo); } } return(listConsumDetail); }
/// <summary> /// 获取在宾客信息清单 /// </summary> /// <param name="listRoomInfo"></param> /// <param name="cStayStatus">该入住单是否在住</param> /// <param name="sStayType">宾客类型,主客Or从客</param> /// <param name="HisStayStatus">宾客是否退房</param> /// <param name="IsCountConsume">是否统计消费</param> /// <returns></returns> public List <CustomerStayModel> GetStayInRoomInfo(List <BasRoomModel> listRoomInfo, char cStayStatus, string sStayType, bool IsCountConsume) { List <CustomerStayModel> listCustomerStayInfo = new List <CustomerStayModel>(); CustomerStayModel mStayInfo = new CustomerStayModel(); ObjectControls oCtrl = new ObjectControls(); foreach (BasRoomModel mRoom in listRoomInfo) { mStayInfo.RoomInfo.RoomIdGroup += Cmn.MakeGroup(mRoom.RoomId.ToString()); } mStayInfo.RoomInfo.RoomIdGroup = Cmn.RemoveLastDou(mStayInfo.RoomInfo.RoomIdGroup); mStayInfo.Status = cStayStatus; mStayInfo.CustomerList = new List <CustomerModel>(); CustomerModel mc = new CustomerModel(); mc.CustomerStayHisInfo = new CustomerStayHisModel(); if (!string.IsNullOrEmpty(sStayType)) { mc.CustomerStayHisInfo.StayType = Cmn.ToChar(sStayType); oCtrl.Add(MCtrl.ByStayType); } mc.CustomerStayHisInfo.HisStatus = cStayStatus == 'I' ? 'E' : 'O'; mStayInfo.CustomerList.Add(mc); if (Cmn.CheckEOF(listRoomInfo)) { oCtrl.Add(MCtrl.ByRoomIdGroup); } oCtrl.Add(MCtrl.ByStayStatus); oCtrl.Add(MCtrl.ByHisStatus); listCustomerStayInfo = bCustomerStay.GetCustomerStayList(mStayInfo, oCtrl); if (Cmn.CheckEOF(listCustomerStayInfo) && IsCountConsume) { foreach (CustomerStayModel mCustomerStay in listCustomerStayInfo) { List <ConsumeDetailModel> listGetConsumeDetail = new List <ConsumeDetailModel>(); ConsumeDetailModel mConsume = new ConsumeDetailModel(); mConsume.StayId = mCustomerStay.StayId; oCtrl.Reset(); oCtrl.Add(MCtrl.ByStayId); listGetConsumeDetail = bConsume.GetConsumeList(mConsume, oCtrl); if (Cmn.CheckEOF(listGetConsumeDetail)) { mCustomerStay.ConSumeDetailList = listGetConsumeDetail; } } } return(listCustomerStayInfo); }
public int InsertConsumeDetail(ConsumeDetailModel mConsume) { CONSUME_DETAIL cd = new CONSUME_DETAIL(); cd.CREATE_DATE = mConsume.CommonInfo.CreateDate; cd.CREATE_USERID = mConsume.CommonInfo.CreateUserId; cd.GOODS_ID = mConsume.GoodsId; cd.NUMBER = mConsume.Number; cd.STAY_ID = mConsume.StayId; cd.TOTAL = mConsume.Total; cd.UNIT_PRICE = mConsume.UnitPrice; cd.UPDATE_DATE = GetDBTime; cd.UPDATE_USERID = mConsume.CommonInfo.UpdateUserId; dc.CONSUME_DETAIL.InsertOnSubmit(cd); dc.SubmitChanges(); return(cd.CONSUME_ID); }
/// <summary> /// 增加消费 /// </summary> private void AddConsume() { try { if (dgvGoodsList.SelectedRows.Count == 0) { return; } if (int.Parse(txtNumber.Text) <= 0 || !cmn.Confirm("确定增加商品" + dgvGoodsList.SelectedRows[0].Cells["GoodsName"].Value.ToString() + " 数量为" + txtNumber.Text)) { return; } int GoodsId = int.Parse(dgvGoodsList.SelectedRows[0].Cells["GoodsId"].Value.ToString()); var query = mCustomerStay.ConSumeDetailList.Where(c => c.GoodsId == GoodsId); ConsumeDetailModel mConsumeNew = new ConsumeDetailModel(); mConsumeNew.GoodsId = GoodsId; mConsumeNew.GoodsInfo = new BasGoodsModel(); mConsumeNew.GoodsInfo.GoodsName = dgvGoodsList.SelectedRows[0].Cells["GoodsName"].Value.ToString(); mConsumeNew.StayId = mCustomerStay.StayId; mConsumeNew.Number = txtNumber.Text.Equals("") ? 1 : cmn.CheckIsDouble(txtNumber, "消费数量"); mConsumeNew.UnitPrice = double.Parse(dgvGoodsList.SelectedRows[0].Cells["Price"].Value.ToString()); mConsumeNew.Total = mConsumeNew.Number * mConsumeNew.UnitPrice; mConsumeNew.CommonInfo = new CommonModel(); mConsumeNew.CommonInfo.CreateUserId = UserInfo.UserId; mConsumeNew.CommonInfo.CreateUserName = UserInfo.UserName; mConsumeNew.CommonInfo.CreateDate = cmn.DateBaseDate; mConsumeNew.CommonInfo.UpdateUserId = UserInfo.UserId; //mCustomerStay.ConSumeDetailList.Add(mConsumeNew); //if (!listAddGoods.Contains(GoodsId)) //{ // listAddGoods.Add(GoodsId); //} txtNumber.Text = "1"; bConsume.InsertConsumeDetail(mConsumeNew); mCustomerStay = hml.GetStayInRoomInfo(mRoomInfo, 'I', "M"); BindConsumeDetail(mCustomerStay.ConSumeDetailList); } catch (Exception err) { cmn.Show(err.Message); } }
/// <summary> /// 获取宾客入住信息,消费明细 /// </summary> /// <param name="mRoom">房间信息</param> /// <param name="cStayStatus">入住状态 I In / O off</param> /// <param name="sStayType">入住类型,主客M从客S,如包含主从则为""</param> /// <returns></returns> public CustomerStayModel GetStayInRoomInfo(BasRoomModel mRoom, char cStayStatus, string sStayType) { CustomerStayModel mStayInfo = new CustomerStayModel(); ObjectControls oCtrl = new ObjectControls(); mStayInfo.RoomId = mRoom.RoomId; mStayInfo.Status = cStayStatus; mStayInfo.CustomerList = new List <CustomerModel>(); CustomerModel mc = new CustomerModel(); mc.CustomerStayHisInfo = new CustomerStayHisModel(); if (!string.IsNullOrEmpty(sStayType)) { mc.CustomerStayHisInfo.StayType = Cmn.ToChar(sStayType); oCtrl.Add(MCtrl.ByStayType); } mc.CustomerStayHisInfo.HisStatus = cStayStatus == 'I' ? 'E' : 'O'; mStayInfo.CustomerList.Add(mc); oCtrl.Add(MCtrl.ByRoomId); oCtrl.Add(MCtrl.ByStayStatus); oCtrl.Add(MCtrl.ByHisStatus); CustomerStayModel mCustomerStay = bCustomerStay.GetCustomerStayInfo(mStayInfo, oCtrl); if (mCustomerStay != null) { List <ConsumeDetailModel> listGetConsumeDetail = new List <ConsumeDetailModel>(); ConsumeDetailModel mConsume = new ConsumeDetailModel(); mConsume.StayId = mCustomerStay.StayId; oCtrl.Reset(); oCtrl.Add(MCtrl.ByStayId); listGetConsumeDetail = bConsume.GetConsumeList(mConsume, oCtrl); if (Cmn.CheckEOF(listGetConsumeDetail)) { mCustomerStay.ConSumeDetailList = listGetConsumeDetail; } } return(mCustomerStay); }
/// <summary> /// 换房逻辑,换房只能从一个已入住房间换到状态为可用的房间. /// </summary> /// <param name="mCustomerStay">入住信息</param> /// <param name="mNewRoomInfo">新房信息</param> /// <param name="dNewRoomRate">新房费用</param> /// <param name="mUserInfo">系统用户信息</param> /// <param name="listSysParameter">系统参数</param> public void ChangeRoom(CustomerStayModel mCustomerStay, BasRoomModel mNewRoomInfo, double dNewRoomRate, SysUserInfoModel mUserInfo, List <SysParameterModel> listSysParameter) { try { #region 将之前房间费用(光房间费用)加入到消费清单中. ConsumeDetailModel mConsume = new ConsumeDetailModel(); BasGoodsModel mGoods = new BasGoodsModel(); mGoods.Type = 'R'; List <BasGoodsModel> listGoods = bGoods.GetGoodsInfo(mGoods, new ObjectControls(MCtrl.ByGoodsType)); if (Cmn.CheckEOF(listGoods)) { mConsume.GoodsId = listGoods[0].GoodsId; } else { throw new Exception("未定义类型的R的商品,该类型为房间费."); } mConsume.StayId = mCustomerStay.StayId; mConsume.UnitPrice = mCustomerStay.RoomRate; RoomStayType eRst = mCustomerStay.RoomStayType == 'D' ? RoomStayType.Day : RoomStayType.Hour; DateTime dtNow = Cmn.DateBaseDate; mConsume.Number = GetCustomerStayDays(mCustomerStay.CommonInfo.StartDate, dtNow, dtNow, eRst, listSysParameter); mConsume.Total = GetTotalRates(mCustomerStay, null, listSysParameter, dtNow, 0.0); mConsume.CommonInfo = new CommonModel(); mConsume.CommonInfo.CreateDate = mCustomerStay.CommonInfo.StartDate; mConsume.CommonInfo.CreateUserId = mUserInfo.UserId; mConsume.CommonInfo.UpdateUserId = mUserInfo.UserId; bConsume.InsertConsumeDetail(mConsume); #endregion #region 是否团队房间 if (mCustomerStay.MainRoomId == mCustomerStay.RoomId) { if (Cmn.Confirm(string.Format("{0}为主房间,变更后{1}将成为主房间,是否继续?", mCustomerStay.RoomInfo.RoomNo, mNewRoomInfo.RoomNo))) { #region 将团队房间的MainRoomId变为新ID List <BasRoomModel> listTeamRoom = GetTeamRoomListByRoomId(mCustomerStay.RoomInfo, 'I'); if (Cmn.CheckEOF(listTeamRoom)) { ObjectControls oCtrl = new ObjectControls(); oCtrl.Add(MCtrl.SetMainRoomId); foreach (BasRoomModel mRoom in listTeamRoom) { CustomerStayModel mCs = new CustomerStayModel(); mCs.RoomId = mRoom.RoomId; mCs.Status = 'I'; ObjectControls oc = new ObjectControls(); oc.Add(MCtrl.ByStayStatus); oc.Add(MCtrl.ByRoomId); mCs = bCustomerStay.GetCustomerStayInfo(mCs, oc); if (mCs != null) { mCs.MainRoomId = mNewRoomInfo.RoomId; bCustomerStay.UpdateCustomerStay(mCs, oCtrl); } } } #endregion } } #endregion #region 将原来房间置为清理,将新房间设置为入住 ObjectControls oCtrlMain = new ObjectControls(); oCtrlMain.Add(MCtrl.SetRoomId); oCtrlMain.Add(MCtrl.SetStartDate); oCtrlMain.Add(MCtrl.SetHours); oCtrlMain.Add(MCtrl.SetRoomRate); mCustomerStay.RoomId = mNewRoomInfo.RoomId; mCustomerStay.CommonInfo.StartDate = Cmn.DateBaseDate; double dDays = GetCustomerStayDays(mCustomerStay.CommonInfo.StartDate, mCustomerStay.CommonInfo.EndDate, mCustomerStay.CommonInfo.StartDate, eRst, listSysParameter); mCustomerStay.Hours = eRst == RoomStayType.Day ? Convert.ToInt32(dDays * 24) : Convert.ToInt32(dDays); mCustomerStay.RoomRate = dNewRoomRate; bCustomerStay.UpdateCustomerStay(mCustomerStay, oCtrlMain); mNewRoomInfo.Status = mCustomerStay.RoomInfo.Status; UpdateRoomStatusByRoomId(mNewRoomInfo, mUserInfo); mCustomerStay.RoomInfo.Status = 'C'; UpdateRoomStatusByRoomId(mCustomerStay.RoomInfo, mUserInfo); #endregion } catch (Exception err) { throw err; } }
public int DeleteConsumeDetail(ConsumeDetailModel mConsume) { return(dConsumeDetail.DeleteConsumeDetail(mConsume)); }
public int UpdateConsumeDetail(ConsumeDetailModel mConsume, ObjectControls oCtrl) { return(dConsumeDetail.UpdateConsumeDetail(mConsume, oCtrl)); }
public int InsertConsumeDetail(ConsumeDetailModel mConsume) { return(dConsumeDetail.InsertConsumeDetail(mConsume)); }
/// <summary> /// 获取消费明细 /// </summary> /// <param name="mConsume"></param> /// <param name="oCtrl"></param> /// <returns></returns> public List <ConsumeDetailModel> GetConsumeList(ConsumeDetailModel mConsume, ObjectControls oCtrl) { return(dConsumeDetail.GetConsumeList(mConsume, oCtrl)); }
public int DeleteConsumeDetail(ConsumeDetailModel mConsume) { string sql = "DELETE FROM CONSUME_DETAIL WHERE CONSUME_ID=" + mConsume.ConsumeId; return(ExcuteNonQuery(sql)); }