Ejemplo n.º 1
0
        public List <BasGoodsModel> GetGoodsInfo(BasGoodsModel mGoods, ObjectControls oCtrl)
        {
            string sql = @"SELECT GOODS_ID, GOODS_NAME, GOODS_UNIT, PRICE, TYPE, STATUS
                            FROM BAS_GOODS_INFO WHERE 1=1 ";

            oCtrl.Helper(oCtrl.Exsit(MCtrl.ByGoodsId) && oCtrl.Append(ref sql, " AND GOODS_ID=" + mGoods.GoodsId));
            oCtrl.Helper(oCtrl.Exsit(MCtrl.ByGoodsName) && oCtrl.Append(ref sql, " AND GOODS_NAME=" + SQL(mGoods.GoodsName)));
            oCtrl.Helper(oCtrl.Exsit(MCtrl.ByGoodsType) && oCtrl.Append(ref sql, " AND TYPE=" + SQL(mGoods.Type)));
            oCtrl.Helper(oCtrl.Exsit(MCtrl.ByGoodsStatus) && oCtrl.Append(ref sql, " AND STATUS=" + SQL(mGoods.Status)));
            sdr = ExecuteReader(sql);
            List <BasGoodsModel> listGoodsInfo = new List <BasGoodsModel>();

            using (sdr)
            {
                while (sdr.Read())
                {
                    BasGoodsModel mGoodsInfo = new BasGoodsModel();
                    mGoodsInfo.GoodsId   = ToInt32(sdr["GOODS_ID"]);
                    mGoodsInfo.GoodsName = ToString(sdr["GOODS_NAME"]);
                    mGoodsInfo.GoodsUnit = ToString(sdr["GOODS_UNIT"]);
                    mGoodsInfo.Price     = ToDouble(sdr["PRICE"]);
                    mGoodsInfo.Type      = ToChar(sdr["TYPE"]);
                    mGoodsInfo.Status    = ToChar(sdr["STATUS"]);
                    listGoodsInfo.Add(mGoodsInfo);
                }
            }
            return(listGoodsInfo);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得商品列表
        /// </summary>
        /// <returns></returns>
        private List <BasGoodsModel> GetGoodsList()
        {
            BasGoodsModel mGoods = new BasGoodsModel();

            mGoods.Status = 'E';
            return(bGoods.GetGoodsInfo(mGoods, new ObjectControls(MCtrl.ByGoodsStatus)));
        }
Ejemplo n.º 3
0
 private void btnGoodsSave_Click(object sender, EventArgs e)
 {
     try
     {
         CheckTextValue(new Object[] { txtGoodsName, txtGoodsPrice, txtGoodsUnit });
         if (!cmn.Confirm("保存商品信息?"))
         {
             return;
         }
         int nGoodsId = 0;
         if (txtGoodsName.Tag != null && txtGoodsName.Tag.ToString() != "")
         {
             nGoodsId = Convert.ToInt32(txtGoodsName.Tag);
         }
         var query = listGoods.Where(c => c.GoodsId == nGoodsId);
         if (query.Count() > 0)
         {
             oCtrl.Reset();
             oCtrl.Add(MCtrl.SetGoodsName);
             oCtrl.Add(MCtrl.SetGoodsStaus);
             oCtrl.Add(MCtrl.SetUnitPrice);
             oCtrl.Add(MCtrl.SetUnit);
             BasGoodsModel mGoods = new BasGoodsModel();
             mGoods.GoodsName = txtGoodsName.Text;
             mGoods.GoodsUnit = txtGoodsUnit.Text;
             mGoods.Price     = cmn.CheckIsDouble(txtGoodsPrice, "商品价格");
             mGoods.Status    = cmn.ToChar(cboGoodsStatus.SelectedValue);
             mGoods.GoodsId   = query.First().GoodsId;
             bGoods.UpdateGoods(mGoods, oCtrl);
         }
         else
         {
             query = listGoods.Where(c => c.GoodsName == txtGoodsName.Text);
             if (query.Count() > 0)
             {
                 cmn.Show("商品已经存在,无法新增!");
                 return;
             }
             BasGoodsModel mGoods = new BasGoodsModel();
             mGoods.GoodsName = txtGoodsName.Text;
             mGoods.GoodsUnit = txtGoodsUnit.Text;
             mGoods.Price     = cmn.CheckIsDouble(txtGoodsPrice, "商品价格");
             mGoods.Status    = cmn.ToChar(cboGoodsStatus.SelectedValue);
             bGoods.InsertGoods(mGoods);
         }
         BindGoodsList();
         tslblStatus.Text   = "保存完毕";
         txtGoodsName.Text  = "";
         txtGoodsName.Tag   = "";
         txtGoodsUnit.Text  = "";
         txtGoodsPrice.Text = "";
     }
     catch (Exception err)
     {
         tslblStatus.Text = err.Message;
     }
 }
Ejemplo n.º 4
0
        public int UpdateGoods(BasGoodsModel mGoods, ObjectControls oCtrl)
        {
            string sql = "UPDATE BAS_GOODS_INFO  SET TYPE=TYPE";

            oCtrl.Helper(oCtrl.Exsit(MCtrl.SetGoodsName) && oCtrl.Append(ref sql, ",GOODS_NAME=" + SQL(mGoods.GoodsName)));
            oCtrl.Helper(oCtrl.Exsit(MCtrl.SetUnit) && oCtrl.Append(ref sql, ",GOODS_UNIT=" + SQL(mGoods.GoodsUnit)));
            oCtrl.Helper(oCtrl.Exsit(MCtrl.SetUnitPrice) && oCtrl.Append(ref sql, ",PRICE=" + SQL(mGoods.Price)));
            oCtrl.Helper(oCtrl.Exsit(MCtrl.SetGoodsStaus) && oCtrl.Append(ref sql, ",STATUS=" + SQL(mGoods.Status)));
            sql += " WHERE GOODS_ID=" + mGoods.GoodsId;
            return(ExcuteNonQuery(sql));
        }
Ejemplo n.º 5
0
        public int InsertGoods(BasGoodsModel mGoods)
        {
            BAS_GOODS_INFO bgi = new BAS_GOODS_INFO
            {
                GOODS_NAME = mGoods.GoodsName,
                GOODS_UNIT = mGoods.GoodsUnit,
                PRICE      = mGoods.Price,
                STATUS     = mGoods.Status,
                TYPE       = 'G'
            };

            dc.BAS_GOODS_INFO.InsertOnSubmit(bgi);
            dc.SubmitChanges();
            return(bgi.GOODS_ID);
        }
Ejemplo n.º 6
0
        private void dgvGoodsList_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            if (!cmn.Confirm("确定删除商品" + e.Row.Cells["GoodsName"].Value))
            {
                e.Cancel = true;
                return;
            }

            var query = listGoods.Where(c => c.GoodsId == Convert.ToInt32(e.Row.Cells["GoodsId"].Value));

            if (query.Count() > 0)
            {
                BasGoodsModel mGoodes = query.First();
                mGoodes.Status = 'D';
                bGoods.UpdateGoods(mGoodes, new ObjectControls(MCtrl.SetGoodsStaus));
            }
        }
Ejemplo n.º 7
0
        /// <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;
            }
        }
Ejemplo n.º 8
0
        public int DeleteGoods(BasGoodsModel mGoods)
        {
            string sql = "DELETE FROM BAS_GOODS_INFO  WHERE GOODS_ID= " + mGoods.GoodsId;

            return(ExcuteNonQuery(sql));
        }
Ejemplo n.º 9
0
 public int UpdateGoods(BasGoodsModel mGoods, ObjectControls oCtrl)
 {
     return(dGoodsDao.UpdateGoods(mGoods, oCtrl));
 }
Ejemplo n.º 10
0
 public int InsertGoods(BasGoodsModel mGoods)
 {
     return(dGoodsDao.InsertGoods(mGoods));
 }
Ejemplo n.º 11
0
 public int DeleteGoods(BasGoodsModel mGoods)
 {
     return(dGoodsDao.DeleteGoods(mGoods));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 获取商品信息
 /// </summary>
 /// <param name="mGoods"></param>
 /// <param name="oCtrl"></param>
 /// <returns></returns>
 public List <BasGoodsModel> GetGoodsInfo(BasGoodsModel mGoods, ObjectControls oCtrl)
 {
     return(dGoodsDao.GetGoodsInfo(mGoods, oCtrl));
 }