protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { int ID = GetSelectedDataKeyID(Grid1); if (e.CommandName == "viewField") { PageContext.Redirect(string.Format("~/Reports/DinnerOrderEdit.aspx?id={0}", ID)); } if (e.CommandName == "stockField") { if (CheckPower("CoreCateringEdit")) { //库存冲减 StockProcess(ID); } else { Alert.Show("您没有反结算的权限!"); } } if (e.CommandName == "stockBack") { if (CheckPower("CoreCateringEdit")) { tm_TabieUsingInfo tm_tabieUsingInfo = Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().GetEntity(ID); //反结算-更新餐台信息状态 tm_Tabie tabieInfo = Core.Container.Instance.Resolve <IServiceTabie>().GetEntity(tm_tabieUsingInfo.TabieID); if (tabieInfo.TabieState == 1) { tabieInfo.TabieState = 4; tabieInfo.CurrentUsingID = tm_tabieUsingInfo.ID; Core.Container.Instance.Resolve <IServiceTabie>().Update(tabieInfo); //反结算-更新就餐开台信息状态 tm_tabieUsingInfo.OrderState = "1"; Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().Update(tm_tabieUsingInfo); //反结算-删除结算信息 IList <ICriterion> qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("TabieUsingID", ID)); tm_TabiePayInfo payInfo = Core.Container.Instance.Resolve <IServiceTabiePayInfo>().GetEntityByFields(qryList); if (payInfo != null) { Core.Container.Instance.Resolve <IServiceTabiePayInfo>().Delete(payInfo); } Alert.Show("请返回营业管理进行反结算处理!"); //刷新 BindGrid(); } else { Alert.Show("餐台当前使用中,不能进行反结算!"); } } else { Alert.Show("您没有反结算的权限!"); } } }
/// <summary> /// 绑定就餐信息 /// </summary> private void BindTabieUingInfo() { tm_TabieUsingInfo tabieUsing = Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().GetEntity(_id); txbPopulation.Text = tabieUsing.Population.ToString(); txbMoneys.Text = string.Format("{0}元", tabieUsing.Moneys.ToString()); txbClearTime.Text = tabieUsing.ClearTime.ToString(); txbOpenTime.Text = tabieUsing.OpenTime.ToString(); txbPrePrice.Text = string.Format("{0}元", tabieUsing.PrePrice.ToString()); txbFactPrice.Text = string.Format("{0}元", tabieUsing.FactPrice.ToString()); switch (tabieUsing.OrderState) { case "1": txtPayType.Text = "就餐中"; break; case "2": txtPayType.Text = "已结账"; break; case "3": txtPayType.Text = string.Format("【免单】{0}", tabieUsing.FreeReason); break; case "4": txtPayType.Text = string.Format("【挂账】{0}", tabieUsing.Charge); break; default: txtPayType.Text = "就餐中"; break; } lblML.Text = string.Format("{0}元", tabieUsing.Erasing.ToString()); lblVipCard.Text = tabieUsing.VipID; IList <ICriterion> qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("TabieUsingID", _id)); //获取支付信息 tm_TabiePayInfo payInfo = Core.Container.Instance.Resolve <IServiceTabiePayInfo>().GetEntityByFields(qryList); if (payInfo != null) { lblCash.Text = string.Format("{0}元", payInfo.CashMoneys.ToString()); lblCard.Text = string.Format("{0}元", payInfo.CreditMoneys.ToString()); lblMember.Text = string.Format("{0}元", payInfo.VipcardMoneys.ToString()); lblWX.Text = string.Format("{0}元", payInfo.OnlineMoneys.ToString()); lblZFB.Text = string.Format("{0}元", payInfo.ZFBMoneys.ToString()); lblGroupNO.Text = payInfo.GroupCardNO; lblGroup.Text = string.IsNullOrEmpty(payInfo.PayWayGroup) || !payInfo.PayWayGroup.Equals("1") ? "" : string.Format("【{0}】{1}元", tabieUsing.GroupName, payInfo.GroupMoneys); } }
/// <summary> /// 结算留存单打印 /// </summary> protected void LocalPrint() { tm_TabieUsingInfo tabieUsingInfo = Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().GetEntity(TabieUsingID); tm_Tabie tabieEntity = Core.Container.Instance.Resolve <IServiceTabie>().GetEntity(tabieUsingInfo.TabieID); IList <ICriterion> qrylist = new List <ICriterion>(); qrylist.Add(Expression.Eq("TabieUsingID", tabieUsingInfo.ID)); tm_TabiePayInfo PayEntity = Core.Container.Instance.Resolve <IServiceTabiePayInfo>().GetEntityByFields(qrylist); StringBuilder sb = new StringBuilder(); StringBuilder count = new StringBuilder(); StringBuilder price = new StringBuilder(); sb.Append("农投良品生活馆\n"); sb.Append("结算单\n"); sb.AppendFormat("桌 位:{0}\n", tabieEntity.TabieName); sb.AppendFormat("账单编号:{0}\n", tabieUsingInfo.OrderNO); sb.AppendFormat("营业日期:{0}\n", DateTime.Now.ToShortDateString()); sb.AppendFormat("开台时间:{0}\n", tabieUsingInfo.OpenTime.ToString("yyyy-MM-dd HH:mm:ss")); sb.AppendFormat("结账时间:{0}\n", DateTime.Parse(dltCloseTabie.Text).ToString("yyyy-MM-dd HH:mm:ss")); sb.AppendFormat("客 数:{0}\n", tabieUsingInfo.Population); sb.AppendFormat("收款机号 \n"); count.Append("\n"); count.Append("\n"); count.Append("\n"); count.Append("\n"); count.Append("\n"); count.Append("\n"); count.Append("\n"); count.Append("\n"); count.AppendFormat("收银员:{0} \n", User.Identity.Name); price.Append("\n"); price.Append("\n"); price.Append("\n"); price.Append("\n"); price.Append("\n"); price.Append("\n"); price.Append("\n"); price.Append("\n"); price.Append("\n"); sb.Append("---------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); sb.Append("菜品名称\n"); count.Append("数量 \n"); price.Append("金额 \n"); sb.Append("---------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); //获取点菜信息 string sql = string.Format("SELECT DishesName,sum(DishesCount) as DishesCount,SUM(Moneys) as Moneys,UnitName,IsFree,DishesType FROM tm_tabiedishesinfo WHERE TabieUsingID={0} GROUP BY DishesName,UnitName,IsFree,DishesType ORDER BY DishesName " , tabieUsingInfo.ID); DataSet ds = DbHelperMySQL.Query(sql); if (ds.Tables[0] != null) { foreach (DataRow row in ds.Tables[0].Rows) { //判断赠送 if (!row["IsFree"].ToString().Equals("1")) { //判断退菜 if (row["DishesType"].ToString().Equals("1")) { sb.AppendFormat("{0}\n", row["DishesName"].ToString()); } if (row["DishesType"].ToString().Equals("2")) { sb.AppendFormat("{0}[退菜]\n", row["DishesName"].ToString()); } //团购菜品 if (row["DishesType"].ToString().Equals("3")) { sb.AppendFormat("{0}[套餐]\n", row["DishesName"].ToString()); } } else { sb.AppendFormat("{0}[赠送]\n", row["DishesName"].ToString()); } count.AppendFormat("{0}{1}\n", row["DishesCount"].ToString(), row["UnitName"].ToString()); price.AppendFormat("{0}\n", row["Moneys"].ToString()); } } sb.Append("-----------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); sb.Append("消费合计:\n"); count.Append("\n"); price.AppendFormat("{0}\n", tabieUsingInfo.Moneys); sb.Append("赠送金额:\n"); count.Append("\n"); price.AppendFormat("{0}\n", tabieUsingInfo.PrePrice); sb.Append("抹零金额:\n"); count.Append("\n"); price.AppendFormat("{0}\n", tabieUsingInfo.Erasing); sb.Append("应付金额:\n"); count.Append("\n"); price.AppendFormat("{0}\n", tabieUsingInfo.FactPrice); sb.AppendFormat("折扣[{0}折]\n", tabieUsingInfo.DisPoint); count.Append("\n"); price.AppendFormat("{0}\n", tabieUsingInfo.Discount); sb.Append("-----------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); //买单支付 if (rblPayType.SelectedValue == "1") { if (!string.IsNullOrEmpty(PayEntity.PayWayCash)) { sb.Append("现金支付:\n"); count.Append("\n"); price.AppendFormat("{0}\n", PayEntity.CashMoneys); } if (!string.IsNullOrEmpty(PayEntity.PayWayCredit)) { sb.Append("刷卡支付:\n"); count.Append("\n"); price.AppendFormat("{0}\n", PayEntity.CreditMoneys); } if (!string.IsNullOrEmpty(PayEntity.PayWayVipcard)) { sb.Append("会员卡支付:\n"); count.Append("\n"); price.AppendFormat("{0}\n", PayEntity.VipcardMoneys); //获取会员卡信息和余额 IList <ICriterion> qryList = new List <ICriterion>(); qryList.Add(Expression.Eq("VIPPhone", tabieUsingInfo.VipID)); tm_vipinfo vipInfo = Core.Container.Instance.Resolve <IServiceVipInfo>().GetEntityByFields(qryList); if (vipInfo != null) { sb.AppendFormat("会员卡:{0}\n", tabieUsingInfo.VipID); count.AppendFormat("余额:{0}\n", vipInfo.VIPCount); price.AppendFormat("\n"); } } if (!string.IsNullOrEmpty(PayEntity.PayWayOnline)) { sb.Append("微信支付:\n"); count.Append("\n"); price.AppendFormat("{0}\n", PayEntity.OnlineMoneys); } if (!string.IsNullOrEmpty(PayEntity.PayWayZFB)) { sb.Append("支付宝支付:\n"); count.Append("\n"); price.AppendFormat("{0}\n", PayEntity.ZFBMoneys); } sb.Append("-----------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); } //美团 if (!string.IsNullOrEmpty(tabieUsingInfo.GroupCardNO)) { sb.AppendFormat("美团【{0}】:\n", tabieUsingInfo.GroupName); count.AppendFormat("{0}\n", tabieUsingInfo.GroupCardNO); price.Append("\n"); sb.Append("-----------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); } //免单 if (rblPayType.SelectedValue == "2") { sb.Append("免单:\n"); price.AppendFormat("{0}\n", tabieUsingInfo.FreeReason); count.Append("\n"); sb.Append("-----------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); } //挂账 if (rblPayType.SelectedValue == "3") { sb.Append("挂账:\n"); count.AppendFormat("{0}\n", tabieUsingInfo.Charge); price.Append("\n"); sb.Append("-----------------------------------------------------------------------------\n"); count.Append("\n"); price.Append("\n"); } sb.Append("地址:渝北区冉家坝龙山路301号\n"); count.Append(" \n"); price.Append("\n"); sb.Append("电话:02367364577\n"); count.Append(" \n"); price.Append("\n"); sb.Append("欢迎光临\n"); count.Append("\n"); price.Append("\n"); LocalPrint(sb.ToString(), count.ToString(), price.ToString()); }
/// <summary> /// 账单结算保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { tm_TabieUsingInfo tabieUsingInfo = Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().GetEntity(TabieUsingID); //保存就餐结算完成时间 string strPayType = rblPayType.SelectedValue; //支付方式 //检查是否有原付款信息,有删除原付款信息 IList <ICriterion> qrylist = new List <ICriterion>(); qrylist.Add(Expression.Eq("TabieUsingID", tabieUsingInfo.ID)); IList <tm_TabiePayInfo> PayEntityList = Core.Container.Instance.Resolve <IServiceTabiePayInfo>().GetAllByKeys(qrylist); foreach (tm_TabiePayInfo payObj in PayEntityList) { Core.Container.Instance.Resolve <IServiceTabiePayInfo>().Delete(payObj); } //结算处理 if (strPayType == "1") //正常支付结算 { //保存结算付款信息 decimal? Amount = 0; tm_TabiePayInfo PayEntity = new tm_TabiePayInfo(); PayEntity.PayTime = tabieUsingInfo.ClearTime; PayEntity.TabieUsingID = TabieUsingID; if (!string.IsNullOrEmpty(nbxVip.Text) && decimal.Parse(nbxVip.Text) > 0) //会员卡支付 { //检查会员卡余额 if (decimal.Parse(nbxVip.Text) > decimal.Parse(lblVipMoney.Text)) { Alert.Show("会员卡余额不足!"); return; } PayEntity.VipcardMoneys = decimal.Parse(nbxVip.Text); PayEntity.PayWayVipcard = "1"; PayEntity.VipCardNO = txtVip.Text; Amount += decimal.Parse(nbxVip.Text); } if (!string.IsNullOrEmpty(nbCash.Text) && decimal.Parse(nbCash.Text) > 0) //现金支付 { PayEntity.CashMoneys = decimal.Parse(nbCash.Text); PayEntity.PayWayCash = "1"; Amount += decimal.Parse(nbCash.Text); } if (!string.IsNullOrEmpty(nbCard.Text) && decimal.Parse(nbCard.Text) > 0) //刷卡支付 { PayEntity.CreditMoneys = decimal.Parse(nbCard.Text); PayEntity.PayWayCredit = "1"; Amount += decimal.Parse(nbCard.Text); } if (!string.IsNullOrEmpty(nbWX.Text) && decimal.Parse(nbWX.Text) > 0) //微信支付 { PayEntity.OnlineMoneys = decimal.Parse(nbWX.Text); PayEntity.PayWayOnline = "1"; Amount += decimal.Parse(nbWX.Text); } if (!string.IsNullOrEmpty(nbZFB.Text) && decimal.Parse(nbZFB.Text) > 0) //支付宝支付 { PayEntity.ZFBMoneys = decimal.Parse(nbZFB.Text); PayEntity.PayWayZFB = "1"; Amount += decimal.Parse(nbZFB.Text); } if (!string.IsNullOrEmpty(nbML.Text) && decimal.Parse(nbML.Text) > 0) //抹零金额 { tabieUsingInfo.Erasing = decimal.Parse(nbML.Text); Amount += decimal.Parse(nbML.Text); } if (!string.IsNullOrEmpty(tabieUsingInfo.GroupName)) //团购金额 { PayEntity.GroupCardNO = tabieUsingInfo.GroupCardNO; PayEntity.PayWayGroup = "1"; PayEntity.GroupMoneys = tabieUsingInfo.GroupMoneys; } //判断填写的实际支付金额和应付金额是否一致 if (Amount != tabieUsingInfo.FactPrice) { Alert.ShowInTop("录入的金额总数与实付金额不匹配", "错误提示", MessageBoxIcon.Warning); return; } //保存结算支付信息 Core.Container.Instance.Resolve <IServiceTabiePayInfo>().Create(PayEntity); //设置就餐信息状态为已结账 tabieUsingInfo.OrderState = "2"; } else if (strPayType == "2") //免单处理 { tabieUsingInfo.FreeReason = ddlFreeReason.SelectedValue; //设置就餐信息状态为免单 tabieUsingInfo.OrderState = "3"; } else //挂账处理 { if (ddlChargeReason.SelectedValue.Equals("0") && string.IsNullOrEmpty(txbChargeReason.Text)) { Alert.ShowInTop("请选择或填入挂账人信息", "错误提示", MessageBoxIcon.Warning); return; } //如果是手填的挂账人,保存 if (!string.IsNullOrEmpty(txbChargeReason.Text.Trim())) { tabieUsingInfo.Charge = txbChargeReason.Text.Trim(); //如果是填写的挂账人,保存到挂账人信息表 tm_Charge chargeInfo = new tm_Charge(); chargeInfo.ChargeName = txbChargeReason.Text.Trim(); chargeInfo.Remark = txbChargeReason.Text.Trim(); Core.Container.Instance.Resolve <IServiceCharge>().Create(chargeInfo); } else { tabieUsingInfo.Charge = ddlChargeReason.SelectedText; } //设置就餐信息状态为挂账 tabieUsingInfo.OrderState = "4"; } Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().Update(tabieUsingInfo); //单元结算单 LocalPrint(); //检查系统设置是否做库存处理 bool IsStock = bool.Parse(ConfigurationManager.AppSettings["IsStock"]); if (IsStock) { //库存冲减 StockProcess(); } //清台并返回餐台列表 CloseTabie(); }
/// <summary> /// 账单结算保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { //获取合并餐台信息 List <ICriterion> qrylist = new List <ICriterion>(); qrylist.Add(Expression.Eq("MergeNO", MergeNO)); IList <tm_TabieUsingInfo> listTabieUsingInfo = Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().Query(qrylist); string strPayType = rblPayType.SelectedValue; //支付方式 StringBuilder groupCard = new StringBuilder(); decimal groupMoney = 0; StringBuilder groupName = new StringBuilder(); decimal totalAmount = 0; //检查是否有原付款信息,有删除原付款信息 qrylist = new List <ICriterion>(); qrylist.Add(Expression.Eq("MergeNO", MergeNO)); IList <tm_TabiePayInfo> PayEntityList = Core.Container.Instance.Resolve <IServiceTabiePayInfo>().GetAllByKeys(qrylist); foreach (tm_TabiePayInfo payObj in PayEntityList) { Core.Container.Instance.Resolve <IServiceTabiePayInfo>().Delete(payObj); } int index = 0; //记录付款信息 foreach (tm_TabieUsingInfo tabieUsingInfo in listTabieUsingInfo) { //保存就餐结算完成时间 tabieUsingInfo.ClearTime = DateTime.Parse(dltCloseTabie.Text); //结算处理 if (strPayType == "1") //正常支付结算 { if (index == 0) { //保存抹零金额,计入第一个餐台信息中 if (!string.IsNullOrEmpty(nbML.Text) && decimal.Parse(nbML.Text) > 0) { tabieUsingInfo.Erasing = decimal.Parse(nbML.Text); } } //设置就餐信息状态为已结账 tabieUsingInfo.OrderState = "2"; } else if (strPayType == "2") //免单处理 { tabieUsingInfo.FreeReason = ddlFreeReason.SelectedValue; //设置就餐信息状态为免单 tabieUsingInfo.OrderState = "3"; } else //挂账处理 { if (ddlChargeReason.SelectedValue.Equals("0") && string.IsNullOrEmpty(txbChargeReason.Text)) { Alert.ShowInTop("请选择或填入挂账人信息", "错误提示", MessageBoxIcon.Warning); return; } //如果是手填的挂账人,保存 if (!string.IsNullOrEmpty(txbChargeReason.Text.Trim())) { tabieUsingInfo.Charge = txbChargeReason.Text.Trim(); //如果是填写的挂账人,保存到挂账人信息表 tm_Charge chargeInfo = new tm_Charge(); chargeInfo.ChargeName = txbChargeReason.Text.Trim(); chargeInfo.Remark = txbChargeReason.Text.Trim(); Core.Container.Instance.Resolve <IServiceCharge>().Create(chargeInfo); } else { tabieUsingInfo.Charge = ddlChargeReason.SelectedText; } //设置就餐信息状态为挂账 tabieUsingInfo.OrderState = "4"; } Core.Container.Instance.Resolve <IServiceTabieUsingInfo>().Update(tabieUsingInfo); //团购金额 if (!string.IsNullOrEmpty(tabieUsingInfo.GroupName)) { groupCard.AppendFormat("{0},", tabieUsingInfo.GroupCardNO); groupMoney += tabieUsingInfo.GroupMoneys; groupName.AppendFormat("{0},", tabieUsingInfo.GroupName); } ////计算应付总额 //totalAmount += tabieUsingInfo.FactPrice; index++; } //计算应付总额 totalAmount = decimal.Parse(labFactPrice.Text); //-----------------------------结算处理----------------------------------- if (strPayType == "1") //正常支付结算 { //保存结算付款信息 decimal? Amount = 0; tm_TabiePayInfo PayEntity = new tm_TabiePayInfo(); PayEntity.PayTime = DateTime.Parse(dltCloseTabie.Text); PayEntity.TabieUsingID = 0; PayEntity.MergeNO = MergeNO; if (!string.IsNullOrEmpty(nbxVip.Text) && decimal.Parse(nbxVip.Text) > 0) //会员卡支付 { //检查会员卡余额 if (decimal.Parse(nbxVip.Text) > decimal.Parse(lblVipMoney.Text)) { Alert.Show("会员卡余额不足!"); return; } PayEntity.VipcardMoneys = decimal.Parse(nbxVip.Text); PayEntity.PayWayVipcard = "1"; PayEntity.VipCardNO = txtVip.Text; Amount += decimal.Parse(nbxVip.Text); } if (!string.IsNullOrEmpty(nbCash.Text) && decimal.Parse(nbCash.Text) > 0) //现金支付 { PayEntity.CashMoneys = decimal.Parse(nbCash.Text); PayEntity.PayWayCash = "1"; Amount += decimal.Parse(nbCash.Text); } if (!string.IsNullOrEmpty(nbCard.Text) && decimal.Parse(nbCard.Text) > 0) //刷卡支付 { PayEntity.CreditMoneys = decimal.Parse(nbCard.Text); PayEntity.PayWayCredit = "1"; Amount += decimal.Parse(nbCard.Text); } if (!string.IsNullOrEmpty(nbWX.Text) && decimal.Parse(nbWX.Text) > 0) //微信支付 { PayEntity.OnlineMoneys = decimal.Parse(nbWX.Text); PayEntity.PayWayOnline = "1"; Amount += decimal.Parse(nbWX.Text); } if (!string.IsNullOrEmpty(nbZFB.Text) && decimal.Parse(nbZFB.Text) > 0) //支付宝支付 { PayEntity.ZFBMoneys = decimal.Parse(nbZFB.Text); PayEntity.PayWayZFB = "1"; Amount += decimal.Parse(nbZFB.Text); } if (!string.IsNullOrEmpty(nbML.Text) && decimal.Parse(nbML.Text) > 0) //抹零金额 { Amount += decimal.Parse(nbML.Text); } if (!string.IsNullOrEmpty(groupCard.ToString())) //团购金额 { PayEntity.GroupCardNO = groupCard.ToString(); PayEntity.PayWayGroup = "1"; PayEntity.GroupMoneys = groupMoney; } //判断填写的实际支付金额和应付金额是否一致 if (Amount != totalAmount) { Alert.ShowInTop("录入的金额总数与实付金额不匹配", "错误提示", MessageBoxIcon.Warning); return; } //保存结算支付信息 Core.Container.Instance.Resolve <IServiceTabiePayInfo>().Create(PayEntity); } //单元结算单 LocalPrint(groupCard.ToString(), groupName.ToString()); //库存冲减 StockProcess(); //清台并返回餐台列表 CloseTabie(); }