예제 #1
0
 protected override void On_ActionDelete(object sender, EventArgs e)
 {
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         int cashID = Utilities.ToInt(EVENTARGUMENT);
         string message;
         if (OrderBLL.DeleteMemberCash(cashID, AppContext.Context.Company, out message))
         {
             OrderBLL.UpdateBalance( );
             ts.Complete( );
         }
         txtMessage.InnerHtml = message;
     }
     catch (Exception ex)
     {
         Logging.Log("FinanceList->On_ActionDelete", ex, true);
         txtMessage.InnerHtml = ex.Message;
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
     On_ActionQuery(sender, e);
 }
예제 #2
0
 public bool ProcessCreateTemp(string maluotkham, long idBenhnhan)
 {
     try
     {
         using (var sp = new TransactionScope())
         {
             using (var sh = new SharedDbConnectionScope())
             {
                 SPs.SpXmlThongTuBHYT917(maluotkham, idBenhnhan).Execute();
                 sh.Dispose();
             }
             sp.Complete();
             return(true);
         }
     }
     catch (Exception ex)
     {
         log.Trace("Lỗi:" + ex.Message);
         return(false);
     }
 }
예제 #3
0
        void Import( )
        {
            DataTable dt = CacheTable(null);
            if (dt == null)
            {
                lblErrorInfo2.Text = "导入数据不存在!";
                return;
            }
            DataColumn cCol = dt.Columns[CHECK_COL];
            string strCheck;
            TransactionScope ts = new TransactionScope( );
            SharedDbConnectionScope ss = new SharedDbConnectionScope( );
            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    strCheck = Utilities.ToString(row[cCol]);
                    if (strCheck == string.Empty || strCheck == "-1")
                        continue;
                    SysMember user = SaveMemberData(row);
                    SaveMemberCash(row, user);
                    SaveMemberCompany(row, user);

                }
                AppContext.Context.Company.MarkClean( );
                AppContext.Context.Company.MarkOld( );
                AppContext.Context.Company.IsUseFinger = false;
                AppContext.Context.Company.Save( );
                OrderBLL.UpdateBalance( );
                ts.Complete( );
                lblErrorInfo2.Text = "导入成功!";
                btnPost.Enabled = false;
            }
            catch (Exception ex)
            {
                Logging.Log("MemberExportIn->Import", ex,true);
                lblErrorInfo2.Text = ex.Message + Environment.NewLine + ex.StackTrace;
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
                tbPost.Visible = true;
                btnPost.Enabled = false;
                btnCheck.Enabled = false;
            }
        }
예제 #4
0
파일: OrderMealBLL.cs 프로젝트: eleooo/App
        public static int ConfirmOrder(int orderId, ref long orderSessionVal, int msnType, string message, string orders, out string msg)
        {
            msg = string.Empty;
            int nResult = -1;
            TransactionScope ts = new TransactionScope( );
            SharedDbConnectionScope ss = new SharedDbConnectionScope( );
            try
            {
                lock (LockScopeAction(orderId))
                {
                    Order order = Order.FetchByID(orderId);
                    if (!CheckSendMessagePostData(order, out msg))
                        goto lbl_return;
                    if ((order.OrderUpdateOn.Value.Ticks) != (orderSessionVal))
                    {
                        msg = "该订单已修改,请重新查看.";
                        nResult = -2;
                        goto lbl_return;
                    }
                    var oldStatus = order.OrderStatus;
                    var chgData = Utilities.JSONToObj<Dictionary<int, OrderDetailItem>>(orders);
                    bool isChanged, hasChangePrice = false;
                    decimal dSum = 0;
                    SysCompany company = SysCompany.FetchByID(order.OrderSellerID);
                    if (msnType == 1) //暂缺或价格调整
                    {
                        OrdersDetail itemDetail = null;
                        var details = GetOrderAllDetailByOrderId(orderId).ToDictionary(d => d.MenuId, d =>
                            {
                                if (d.MenuId < 0)
                                    itemDetail = d;
                                return d;
                            });
                        //check sum
                        if (itemDetail != null)
                        {
                            decimal itemChgSum = chgData.Values.Sum(item =>
                            {
                                if (item.IsCompanyItem)
                                {
                                    if (item.NewPrice > 0)
                                    {
                                        itemDetail.IsChgPrice = true;
                                        return item.NewPrice;
                                    }
                                    else
                                        return item.OrderPrice;
                                }
                                else
                                    return 0;
                            });
                            if (itemChgSum <= itemDetail.OrderPrice.Value)
                            {
                                msg = "餐点调的新价不能小于促销项目的现金支付金额.";
                                goto lbl_return;
                            }
                            else if (itemDetail.IsChgPrice.Value)
                                CompanyItemBLL.UpdateCompanyItemSum(itemDetail.MenuId, itemChgSum);
                            dSum = itemDetail.OrderPrice.Value;
                        }
                        //bool isOutOfStock;
                        foreach (var item in chgData.Values)
                        {
                            isChanged = false;
                            var detail = details.ContainsKey(item.MenuId) ? details[item.MenuId] : (OrdersDetail)null;
                            if (detail != null)
                            {
                                if (detail.IsOutOfStock != item.IsOutOfStock)
                                {
                                    detail.IsOutOfStock = item.IsOutOfStock;
                                    MealMenuBLL.ChangeMenuOutOfStokcStatus(item.MenuId, item.IsOutOfStock);
                                    isChanged = true;
                                    if (item.IsOutOfStock)
                                        order.HasOutOfStock = item.IsOutOfStock;
                                }

                                if (item.NewPrice > 0 && detail.OrderPrice.Value != item.NewPrice)
                                {
                                    detail.OrderPrice = item.NewPrice;
                                    detail.IsChgPrice = true;
                                    hasChangePrice = true;
                                    isChanged = true;
                                    MealMenuBLL.ChangeMenuPrice(item.MenuId, item.NewPrice);
                                }

                                if (!detail.IsOutOfStock.Value)
                                    dSum += detail.OrderQty.Value * detail.OrderPrice.Value;
                                if (isChanged)
                                    detail.Save( );
                            }
                        }
                        dSum = Math.Round(dSum, 1);
                    }
                    isChanged = false;

                    SysMember user = SysMember.FetchByID(order.OrderMemberID);
                    if (msnType == 1 || hasChangePrice) //某菜单缺货或价格更改
                    {
                        isChanged = true;
                        order.OrderSum = dSum;
                        order.OrderSumOk = order.ServiceSum.HasValue ? (order.ServiceSum.Value + dSum) : dSum;
                        order.OrderPay = order.ServiceSum.HasValue ? (order.ServiceSum.Value + dSum) : dSum;
                        order.OrderPrePoint = (RewardBLL.OrderMealRewardRate(company) / 100M) * dSum; //赠送积分
                        order.OrderRate = RewardBLL.OrderMealRewardRate(company) / 100M;  //赠送比例
                    }

                    if (msnType == 2 || msnType == 4) //商家不外送,订单取消
                    {
                        isChanged = true;
                        if (msnType == 2)
                            order.IsNonOut = true;
                        order.OrderStatus = (int)OrderStatus.Canceled;
                        order.OrderUpdateOn = DateTime.Now;
                        if (!CompanyItemBLL.CancelMemberMealItem(order, out msg))
                            goto lbl_return;
                        RewardBLL.CancelRewardMemberPointForOrderMeal(order);
                    }
                    else //if (msnType != 3)  //自定义回复
                    {
                        if (msnType != 3 ||
                            (msnType == 3 && (oldStatus == (int)OrderStatus.NotStart || oldStatus == (int)OrderStatus.Modified)))
                            order.OrderStatus = (int)OrderStatus.InProgress;
                        order.OrderUpdateOn = DateTime.Now;
                        order.MsnType = msnType == 3 && oldStatus == (int)OrderStatus.InProgress ? 0 : msnType;
                        order.ModifiedOn = DateTime.Now;
                        isChanged = true;
                    }
                    //if (msnType == 0 || (msnType == 1 && !order.HasOutOfStock.Value))
                    //{
                    //    order.OrderPoint = order.OrderPrePoint;
                    //}

                    if (!order.OrderOper.HasValue || order.OrderOper.Value == 0)
                        order.OrderOper = AppContextBase.Context.User.Id;
                    order.Save( );

                    if (msnType == 0 || (msnType == 1 && !order.HasOutOfStock.Value))
                    {
                        RewardBLL.RewardMemberPointForOrderMeal(user, company, order);
                        //OrderBLL.UpdateBalance( );
                    }
                    RemoveLockScopeAction(orderId);
                    ts.Complete( );
                    ss.Dispose( );
                    ss = null;
                    ts.Dispose( );
                    ts = null;
                    OrderProgressBLL.AddOrderConfirmLog(order, company, msnType, hasChangePrice, message);
                    string msnContent = string.Empty;
                    if (msnType == 0)
                    {
                        if (UserIsFirstOrder(order.OrderMemberID))
                        {
                            msnContent = string.Format("亲爱的用户:{0}已经收到您的订单,餐厅正在备餐。您本次订单总计{1}元。预计{2}分钟左右为您送达(仅供参考,高峰时段以实际送达时间为准)。",
                                                        company.CompanyName, order.OrderSumOk, company.OrderElapsed);

                        }
                    }
                    else if (msnType == 1 && order.HasOutOfStock.HasValue && order.HasOutOfStock.Value)
                        msnContent = "亲爱的用户:" + message;
                    else if (msnType == 2)
                        msnContent = "亲爱的用户:很抱歉," + company.CompanyName + "表示,当前暂不提供外送,请选择其他餐厅。";
                    else if (msnType == 3)
                        msnContent = "亲爱的用户:" + message;
                    if (!string.IsNullOrEmpty(msnContent))
                    {
                        int logId;
                        string phone = string.IsNullOrEmpty(user.MemberMsnPhone) ? user.MemberPhoneNumber : user.MemberMsnPhone;
                        if (!MsnBLL.SendMessage(phone, msnContent, order.Id, out msg, out logId))
                            goto lbl_return;
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                Logging.Log("OrderMealBLL->ConfirmOrder", ex, true);
                goto lbl_return;
            }
            finally
            {
                if (ss != null)
                    ss.Dispose( );
                if (ts != null)
                    ts.Dispose( );
            }
            msg = "发送成功";
            nResult = 0;
            orderSessionVal = GetOrderUpdateOn(orderId).Ticks;
            lbl_return:
            RemoveLockScopeAction(orderId);
            return nResult;
        }
예제 #5
0
 protected override void On_ActionAdd(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtMoveMember.Value))
     {
         lblPhoneInfo.InnerHtml = "请输入会员账号";
         goto lbl_return;
     }
     if (string.IsNullOrEmpty(txtMoveSum.Value))
     {
         lblPointInfo.InnerHtml = "请输入整数";
         goto lbl_return;
     }
     int dMoveSum;
     if (!int.TryParse(txtMoveSum.Value, out dMoveSum) || dMoveSum <= 0)
     {
         lblPointInfo.InnerHtml = "请输入大于零整数";
         goto lbl_return;
     }
     SysMember toUser = UserBLL.GetUserByPhoneNum(txtMoveMember.Value);
     if (toUser == null)
     {
         lblPhoneInfo.InnerHtml = "输入的会员账号不存在.";
         goto lbl_return;
     }
     SysMember user = SysMember.FetchByID(CurrentUser.Id);
     if (dMoveSum > user.MemberBalance)
     {
         lblMessage.InnerHtml = string.Format("你的余额为:{0},本次需要转移:{1},余额不足以支付本次转移.", user.MemberBalance, dMoveSum);
         goto lbl_return;
     }
     if (toUser.Id == user.Id)
     {
         lblMessage.InnerHtml = "你不能将积分转移给自己,请输入其他会员的账号!";
         goto lbl_return;
     }
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         SysMemberMove m = new SysMemberMove
         {
             MoverMemberIDOld = user.Id,
             MoverMemberIDNew = toUser.Id,
             MoverDate = DateTime.Now,
             MoverMemberIDPoint = dMoveSum
         };
         m.Save( );
         string memo = string.Format("已转出{1}个积分给{0}", toUser.MemberPhoneNumber, dMoveSum);
         new Payment
         {
             PaymentDate = DateTime.Now,
             PaymentCode = string.Empty,
             PaymentEmail = string.Empty,
             PaymentCompanyID = 0,
             PaymentMemberID = user.Id,
             PaymentMemo = memo,
             PaymentStatus = 1,
             PaymentSum = -dMoveSum,
             PaymentType = (int)PaymentType.Move,
             PaymentOrderID = m.MoveID
         }.Save( );
         new Payment
         {
             PaymentDate = DateTime.Now,
             PaymentCompanyID = 0,
             PaymentCode = string.Empty,
             PaymentEmail = string.Empty,
             PaymentMemberID = toUser.Id,
             PaymentMemo = string.Format("已收到{0}转入的{1:0.00}个积分", user.MemberPhoneNumber, dMoveSum),
             PaymentStatus = 1,
             PaymentSum = dMoveSum,
             PaymentType = (int)PaymentType.Move,
             PaymentOrderID = m.MoveID
         }.Save( );
         OrderBLL.UpdateBalance( );
         ts.Complete( );
         txtMoveMember.Value = "";
         txtMoveSum.Value = "";
         lblMessage.InnerHtml = "积分转账成功";
     }
     catch (Exception ex)
     {
         Logging.Log("MyBalanceMove->On_ActionAdd", ex, true);
         lblMessage.InnerHtml = ex.Message;
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
     lbl_return:
     On_ActionQuery(sender, e);
 }
예제 #6
0
 private static bool SaveOrder(SysCompany company, SysMemberItem mItem, SysCompanyItem cItem, SysMember user, out string message)
 {
     message = string.Empty;
     //Order order = new Order
     //{
     //    OrderCode = OrderBLL.GetOrderCode(company),
     //    OrderCard = string.Empty,
     //    OrderDate = DateTime.Now,
     //    OrderDateDeliver = DateTime.Now,
     //    OrderDateUpload = DateTime.Now,
     //    OrderMemberID = user.Id,
     //    OrderMemo = string.Empty,
     //    OrderProduct = "优惠消费",
     //    OrderQty = 0,
     //    OrderRateSale = 0,
     //    OrderRate = 0,
     //    OrderPoint = 0,
     //    OrderSellerID = company.Id,
     //    OrderStatus = 1,
     //    OrderSum = cItem.ItemSum,
     //    OrderSumOk = cItem.ItemSum,
     //    OrderPay = 0,
     //    OrderPayCash = 0,
     //    OrderPayPoint = mItem.ItemPoint,
     //    OrderType = (int)OrderType.CompanyItem
     //};
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         //order.Save( );
         //if (mItem.ItemPoint.HasValue && mItem.ItemPoint.Value > 0)
         //{
         //    new Payment
         //    {
         //        PaymentCode = order.OrderCode,
         //        PaymentCompanyID = company.Id,
         //        PaymentDate = order.OrderDate,
         //        PaymentEmail = string.Empty,
         //        PaymentMemberID = user.Id,
         //        PaymentMemo = string.Format("{0}抢购{1}的优惠项目,并且使用{2}个积分抵扣", user.MemberPhoneNumber, company.CompanyName, -mItem.ItemPoint.Value),
         //        PaymentOrderID = order.Id,
         //        PaymentStatus = 1,
         //        PaymentSum = -mItem.ItemPoint.Value,
         //        PaymentType = (int)PaymentType.CompanyItem
         //    }.Save( );
         //}
         //如果是联盟商家则更新积分状态
         CompanyType companyType = Formatter.ToEnum<CompanyType>(company.CompanyType);
         Payment p = Payment.FetchByID(mItem.PaymentID.Value);
         if (p != null)
         {
             p.PaymentStatus = 1;
             p.Save( );
         }
         mItem.ItemStatus = (int)MemberCompanyItemStatus.Completed;
         mItem.SetDate = DateTime.Now;
         mItem.Save( );
         cItem.ItemUsed = Utilities.ToInt(cItem.ItemUsed) + 1;
         cItem.Save( );
         OrderBLL.UpdateBalance( );
         ts.Complete( );
         message = string.Format("结算成功,{0}使用{1}个积分购得{2}", user.MemberFullname, mItem.ItemPoint, cItem.ItemTitle);
         return true;
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return false;
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
 }
예제 #7
0
        public static bool ClickCompanyItem(SysCompany company, SysMember user, DateTime dtDate, SysCompanyItem item, out int memberItemID, out string message)
        {
            memberItemID = 0;
            if (item == null || user == null)
            {
                message = "参数错误!";
                goto lbl_end;
            }

            if (item.ItemClicked >= item.ItemAmount)
            {
                message = "已经达到了最大可{ItemType}的数量";
                goto lbl_end;
            }
            //check ItemLimitOnce
            if (CheckCompanyItemOnceLimit(company.Id, user.Id))
            {
                message = ItemCheckResult[-3];
                goto lbl_end;
            }
            decimal userLastOrderSum = UserBLL.GetUserLastMonthOrderSum(user.Id);
            int result = CompanyItemBLL.ExecuteCheckFunc(user.Id, item.ItemID, userLastOrderSum);
            if (result < 0)
            {
                message = ItemCheckResult.ContainsKey(result) ? ItemCheckResult[result] : "你无权{ItemType}此优惠项目!";
                goto lbl_end;
            }
            //判断会员积分是否足够
            decimal point = DB.Select(SysMember.Columns.MemberBalance).From<SysMember>( )
                              .Where(SysMember.IdColumn).IsEqualTo(user.Id)
                              .ExecuteScalar<decimal>( );
            if (item.ItemPoint.HasValue && point < item.ItemPoint.Value)
            {
                message = "您的账户积分余额不足,无法{ItemType}^_^";
                goto lbl_end;
            }
            SysMemberItem data = new SysMemberItem
            {
                CompanyID = item.CompanyID,
                CompanyItemID = item.ItemID,
                ItemDate = dtDate,
                OrderDate = DateTime.Now,
                MemberID = user.Id,
                OrderSum = userLastOrderSum,
                ItemPoint = item.ItemPoint,
                ItemStatus = (int)MemberCompanyItemStatus.InProgress,
                SetDate = null,
                IsCanModifiedDate = true,
                PaymentID = 0,
                OrderID = 0
            };
            TransactionScope ts = new TransactionScope( );
            SharedDbConnectionScope ss = new SharedDbConnectionScope( );
            try
            {
                if (item.ItemPoint.HasValue && item.ItemPoint.Value > 0)
                {
                    Payment p = new Payment
                    {
                        PaymentCode = string.Empty,
                        PaymentCompanyID = item.CompanyID,
                        PaymentDate = data.OrderDate.Value,
                        PaymentEmail = string.Empty,
                        PaymentMemberID = user.Id,
                        PaymentMemo = string.Format("抢购【{0}】的优惠项目,并使用{1:0.00}个积分消费", company.CompanyName, item.ItemPoint.Value),
                        PaymentOrderID = 0,
                        PaymentStatus = 2,
                        PaymentSum = -item.ItemPoint.Value,
                        PaymentType = (int)PaymentType.CompanyItem
                    };
                    p.Save( );
                    data.PaymentID = p.Id;
                }
                data.Save( );
                item.ItemClicked = Utilities.ToInt(item.ItemClicked) + 1;
                item.Save( );
                OrderBLL.UpdateBalance( );
                ts.Complete( );
                message = "{ItemType}成功";
                memberItemID = data.ItemID;
                return true;
            }
            catch (Exception ex)
            {
                message = "{ItemType}失败:" + ex.Message;
                Logging.Log("CompanyItemBLL->ClickCompanyItem", ex, true);
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
            }
            lbl_end:
            return false;
        }
예제 #8
0
        public static bool CancelCompanyItem(SysMember user, SysCompanyItem companyItem, SysMemberItem memberItem, out string message)
        {
            message = string.Empty;
            if (companyItem == null || user == null || memberItem == null)
            {
                message = "参数错误!";
                goto lbl_end;
            }
            if (companyItem.IsCanDel.HasValue && companyItem.IsCanDel.Value != 1)
            {
                message = "本单不支持退订";
                goto lbl_end; ;
            }
            if (memberItem.ItemStatus == (int)MemberCompanyItemStatus.Completed)
            {
                message = "此单你已经消费 ,不能再退订";
                goto lbl_end;
            }
            TransactionScope ts = null;
            SharedDbConnectionScope ss = null;
            try
            {
                ts = new TransactionScope( );
                ss = new SharedDbConnectionScope( );

                if (memberItem.PaymentID.HasValue)
                    Payment.Delete(memberItem.PaymentID.Value);
                SysMemberItem.Delete(memberItem.ItemID);
                companyItem.ItemClicked = companyItem.ItemClicked.Value - 1;
                companyItem.Save( );
                ts.Complete( );

                message = "退订成功";
                return true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Logging.Log("CompanyItemBLL->CancelCompanyItem", ex, true);
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
            }
            lbl_end:
            return false;
        }
예제 #9
0
        protected override void On_ActionEdit(object sender, EventArgs e)
        {
            int companyID = Utilities.ToInt(EVENTARGUMENT);
            if (companyID <= 0)
            {
                txtMessage.InnerHtml = "结算商家参数错误!";
                goto lable_end;
            }
            string sPayInput = Params[string.Format("CompanyPay_{0}", companyID)];
            if (string.IsNullOrEmpty(sPayInput))
            {
                txtMessage.InnerHtml = "请输入结算金额!";
                goto lable_end;
            }
            decimal dPay = Math.Round(Utilities.ToDecimal(sPayInput));
            if (dPay == 0)
            {
                txtMessage.InnerHtml = "结算金额不能为零";
                goto lable_end;
            }

            SysCompany company = SysCompany.FetchByID(companyID);
            if (company == null)
            {
                txtMessage.InnerHtml = "结算商家参数错误!";
                goto lable_end;
            }
            if (Math.Abs(dPay) > Math.Abs(Utilities.ToDecimal(company.CompanyBalance)))
            {
                txtMessage.InnerHtml = "结算积分不能大于商家现有的积分余额!";
                goto lable_end;
            }
            string payMemo;
            //本次结算积分差额为{0}分,已向【{1}】支付{2}元
            //本次结算积分差额为{0}分,已向【{1}】收取{2}元
            if (dPay > 0)
                payMemo = string.Format("本次结算积分差额为{0}分,【{1}】已向【乐多分】收取{2}元", Math.Abs(dPay), company.CompanyName, Math.Abs(dPay));
            else
                payMemo = string.Format("本次结算积分差额为{0}分,【{1}】已向【乐多分】支付{2}元", Math.Abs(dPay), company.CompanyName, Math.Abs(dPay));
            TransactionScope ts = new TransactionScope( );
            SharedDbConnectionScope ss = new SharedDbConnectionScope( );
            try
            {
                SysMember mainAccount = UserBLL.MainAccount;
                new Payment
                {
                    PaymentCode = string.Empty,
                    PaymentDate = DateTime.Now,
                    PaymentCompanyID = companyID,
                    PaymentMemberID = mainAccount.Id,
                    PaymentSum = dPay,
                    PaymentStatus = 1,
                    PaymentType = (int)(PaymentType.SetMethod),
                    PaymentOrderID = 0,
                    PaymentEmail = string.Empty,
                    PaymentMemo = payMemo
                }.Save(AppContext.Context.User.Id);
                OrderBLL.UpdateBalance( );
                ts.Complete( );
            }
            catch (Exception ex)
            {
                txtMessage.InnerHtml = ex.Message;
                Logging.Log("FinancePayPoint->On_ActionEdit", ex, true);
                goto lable_end;
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
            }
            txtMessage.InnerHtml = payMemo;
            lable_end:
            this.On_ActionQuery(sender, e);
        }
예제 #10
0
 public bool SaveCompanyAdForClient(DataTable dtCompanyAd, DataTable dtPointSetting, byte[] fileData, string fileName, out int adsID, out string message)
 {
     message = string.Empty;
     adsID = 0;
     TransactionScope ts = new TransactionScope();
     SharedDbConnectionScope ss = new SharedDbConnectionScope();
     try
     {
         SysCompanyAd ad = SubSonic.Utilities.EntityFormat.TableToEntity<SysCompanyAd>(dtCompanyAd);
         //SysCompanyAdsPointSetting point = SubSonic.Utilities.EntityFormat.TableToEntity<SysCompanyAdsPointSetting>(dtPointSetting);
         //SysCompanyAdsClickSetting click = SubSonic.Utilities.EntityFormat.TableToEntity<SysCompanyAdsClickSetting>(dtClickSetting);
         if (ad == null || dtPointSetting == null)
         {
             message = "参数异常";
             return false;
         }
         if (dtPointSetting.Rows.Count == 0)
         {
             message = "奖励设置的行数为零";
             return false;
         }
         ad.ValidateWhenSaving = false;
         ad.AdsDate = DateTime.Now;
         ad.AdsPic = null;
         ad.MarkNew();
         ad.Save();
         adsID = ad.AdsID;
         if (fileData != null && fileData.Length > 0 && !string.IsNullOrEmpty(fileName))
         {
             var result = FileUpload.SaveUploadFile(fileData, FileType.Image, SaveType.CompanyAds, fileName, out message, true, adsID.ToString( ));
             ad.AdsPic = result != null ? result.RelPath : string.Empty;
             ad.Save();
         }
         foreach (DataRow row in dtPointSetting.Rows)
         {
             SysCompanyAdsPointSetting p = new SysCompanyAdsPointSetting();
             p.AdsID = ad.AdsID;
             p.OrderSumLimit = Utilities.ToDecimal(row[0]);
             p.AdsPoint = Utilities.ToDecimal(row[1]);
             p.ValidateWhenSaving = false;
             p.Save();
         }
         ts.Complete();
         message = "保存成功";
         return true;
     }
     catch (Exception ex)
     {
         Logging.Log("WebRestService->SaveCompanyAdForClient", ex, true);
         message = ex.Message;
         return false;
     }
     finally
     {
         ss.Dispose();
         ts.Dispose();
     }
 }
예제 #11
0
 protected override void On_ActionEdit(object sender, EventArgs e)
 {
     string argment = Utilities.FromBase64String(EVENTARGUMENT);
     string[] argArr = argment.Split(new char[] { '|' });
     int companyID = Utilities.ToInt(argArr[0]);
     if (companyID <= 0)
     {
         txtInfo.InnerText = "结算参数错误 companyID = 0,请重试!";
         goto lable_end;
     }
     SysCompany company = SysCompany.FetchByID(companyID);
     if (company == null)
     {
         txtInfo.InnerText = "结算参数错误 company = null,请重试!";
         goto lable_end;
     }
     string sPayRateInput = Params[string.Format("CompanyPayRate_{0}", companyID)];
     if (string.IsNullOrEmpty(sPayRateInput))
     {
         txtInfo.InnerText = "结算金额不能为零或佣金比例不能小于等于零!";
         goto lable_end;
     }
     decimal dPayRate = Convert.ToDecimal(sPayRateInput);
     if (dPayRate == 0)
     {
         txtInfo.InnerText = "结算金额不能为零或佣金比例不能小于等于零!";
         goto lable_end;
     }
     DateTime dtPayDate = Convert.ToDateTime(txtPayDate.Value);
     if (dtPayDate >= DateTime.Today)
     {
         txtInfo.InnerText = "不能结算当天之后的日期!";
         goto lable_end;
     }
     //dtPayDate = dtPayDate.AddDays(1);
     decimal dMemberCashSum = Convert.ToDecimal(argArr[1]);
     decimal dMemberPaySum = Convert.ToDecimal(argArr[2]);
     DateTime dt = GetMinOrderDate(company.Id);
     DateTime dtBegin = Utilities.ToDateTime(argArr[3]);
     if (dtBegin < dt)
         dtBegin = dt;
     decimal dSum = dMemberCashSum + dMemberPaySum;
     if (dPayRate <= 0 || dSum <= 0)
     {
         txtInfo.InnerText = "结算金额不能为零或佣金比例不能小于等于零!";
         goto lable_end;
     }
     decimal dRate = dPayRate / 100M;
     decimal dPaySum = dSum * dRate;
     string payMemo = string.Format(ResBLL.GetRes("FinancePayRate_PayMemo", "乐多分向{0}收取了佣金{1}元;", "商家佣金结算描述信息"), company.CompanyName, dPaySum);
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         new PaymentRate
         {
             PaymentRateCompanyID = company.Id,
             PaymentRateDate = DateTime.Now,
             PaymentRateDateStart = dtBegin,
             PaymentRateDateEnd = dtPayDate,
             PaymentRateMemo = payMemo,
             PaymentRateRate = dRate, //佣金比例
             PaymentRateStatus = 1,
             PaymentRateCash = dMemberCashSum, //储值金额
             PaymentRateSale = dMemberPaySum,  //销售金额
             PaymentRateSum = dPaySum          //佣金金额
         }.Save( );
         OrderBLL.UpdateBalance( );
         ts.Complete( );
     }
     catch (Exception ex)
     {
         txtInfo.InnerHtml = ex.Message;
         Logging.Log("FinancePay->On_ActionEdit", ex, true);
         goto lable_end;
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
     txtInfo.InnerText = payMemo;
     lable_end:
     this.On_ActionQuery(sender, e);
 }
예제 #12
0
        protected override void On_ActionAdd(object sender, EventArgs e)
        {
            if (Utilities.IsNull(txtSupportSubject.Text))
            {
                txtMessage.InnerHtml = "请输入咨询的标题!";
                return;
            }

            SysSupport support = SysSupport.FetchByID(Id);
            if (support == null)
            {
                support = new SysSupport( );
                support.SupportIsRead = false;
                support.SupportItem = 1;
                support.SupportProductID = 0;
                support.SupportFid = CurrentUser.Id;
                support.SupportPhoto = string.Empty;
                support.SupportRating = 1;
                support.SupportRatingReason = string.Empty;
                support.SupportStatus = 1;
                support.SupportTid = 0;
                support.SupportType = 1;
                support.SupportDate = DateTime.Now;
                support.SupportDateFinish = DateTime.MinValue.AddYears(0x76c);
                support.SupportDateReply = DateTime.MinValue.AddYears(0x76c);
                support.SupportAttach = string.Empty;
            }
            TransactionScope ts = new TransactionScope( );
            SharedDbConnectionScope ss = new SharedDbConnectionScope( );
            try
            {
                if (!Utilities.IsNull(txtSupportPhoto.Value) && !string.IsNullOrEmpty(txtSupportPhoto.PostedFile.FileName))
                {
                    string message;
                    var result = Eleooo.Common.FileUpload.SaveUploadFile(txtSupportPhoto.PostedFile, FileType.Image | FileType.Zip | FileType.Zip, SaveType.Support, out message, true);
                    if (result == null)
                    {
                        txtMessage.InnerHtml = message;
                        return;
                    }
                    support.SupportPhoto = result.PhyPath;
                }
                support.SupportSubject = txtSupportSubject.Text;
                support.SupportContent = HttpUtility.HtmlEncode(txtSupportContent.Text);
                support.Save( );
                _id = support.SupportId;
                new SysSupportMessage
                {
                    SupportMsgSid = _id,
                    SupportMsgDate = DateTime.Now,
                    SupportMsgFid = support.SupportFid,
                    SupportMsgTid = 0,
                    SupportMsgIsAsk = false,
                    SupportMsgIsRead = false,
                    SupportMsgPhoto = support.SupportPhoto,
                    SupportMsgMemo = string.IsNullOrEmpty(support.SupportContent) ? support.SupportSubject : support.SupportContent
                }.Save( );
                ts.Complete( );
                txtMessage.InnerHtml = "保存成功!";
            }
            catch (Exception ex)
            {
                Logging.Log("Company.SupportEdit->On_ActionAdd", ex, true);
                txtMessage.InnerHtml = ex.Message;
            }
            finally
            {
                ss.Dispose( );
                ts.Dispose( );
            }
            On_ActionQuery(sender, e);
        }
예제 #13
0
        public ActionResult LuuHoibenhvaChandoan(KcbChandoanKetluan objDiagInfo, KcbDonthuocChitiet objChitiet, bool luudulieutiemchung)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        if (objChitiet != null)
                        {
                            objChitiet.IsNew = false;
                            if (objDiagInfo != null)
                            {
                                objChitiet.PhanungSautiem    = objDiagInfo.PhanungSautiemchung;
                                objChitiet.Xutri             = objDiagInfo.HuongDieutri;
                                objChitiet.KetQua            = objDiagInfo.Ketluan;
                                objChitiet.KetluanNguyennhan = objDiagInfo.KetluanNguyennhan;
                            }
                            objChitiet.MarkOld();
                            objChitiet.Save();
                        }
                        if (objDiagInfo != null)
                        {
                            log.Trace("1. Bắt đầu lưu chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                            if (objDiagInfo.IsNew)
                            {
                                //  objDiagInfo.Save();
                                SPs.SpKcbThemmoiChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdKham,
                                                                objDiagInfo.IdBenhnhan,
                                                                objDiagInfo.MaLuotkham, objDiagInfo.IdBacsikham, objDiagInfo.NgayChandoan,
                                                                objDiagInfo.NguoiTao,
                                                                objDiagInfo.NgayTao, objDiagInfo.IdKhoanoitru, objDiagInfo.IdBuonggiuong,
                                                                objDiagInfo.IdBuong, objDiagInfo.IdGiuong
                                                                , objDiagInfo.IdPhieudieutri, objDiagInfo.Noitru, objDiagInfo.IdPhongkham,
                                                                objDiagInfo.TenPhongkham, objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap
                                                                , objDiagInfo.Nhiptim, objDiagInfo.Nhiptho, objDiagInfo.Cannang,
                                                                objDiagInfo.Chieucao, objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong,
                                                                objDiagInfo.HuongDieutri, objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau
                                                                , objDiagInfo.Chandoan, objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh,
                                                                objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaytao, objDiagInfo.TenMaytao,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet
                                                                , objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt
                                                                ).Execute();
                                log.Trace("1.1 Thêm mới lưu chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                            }
                            else
                            {
                                SPs.SpKcbCapnhatChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdBacsikham,
                                                                objDiagInfo.NgayChandoan, objDiagInfo.NguoiSua, objDiagInfo.NgaySua,
                                                                objDiagInfo.IdPhieudieutri
                                                                , objDiagInfo.Noitru, objDiagInfo.IdPhongkham, objDiagInfo.TenPhongkham,
                                                                objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap, objDiagInfo.Nhiptim,
                                                                objDiagInfo.Nhiptho, objDiagInfo.Cannang, objDiagInfo.Chieucao
                                                                , objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong, objDiagInfo.HuongDieutri,
                                                                objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau, objDiagInfo.Chandoan,
                                                                objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh
                                                                , objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaysua, objDiagInfo.TenMaysua,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet,
                                                                objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt).Execute();
                                log.Trace("1.2 Cập nhật chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                                // objDiagInfo.MarkOld();

                                //  objDiagInfo.Save();
                            }
                            if (luudulieutiemchung && objChitiet == null)
                            {
                                new Update(KcbDonthuocChitiet.Schema)
                                .Set(KcbDonthuocChitiet.Columns.PhanungSautiem).EqualTo(objDiagInfo.PhanungSautiemchung)
                                .Set(KcbDonthuocChitiet.Columns.Xutri).EqualTo(objDiagInfo.HuongDieutri)
                                .Set(KcbDonthuocChitiet.Columns.KetQua).EqualTo(objDiagInfo.Ketluan)
                                .Set(KcbDonthuocChitiet.Columns.KetluanNguyennhan).EqualTo(objDiagInfo.KetluanNguyennhan)
                                .Where(KcbDonthuocChitiet.Columns.IdKham).IsEqualTo(objDiagInfo.IdKham)
                                .Execute();
                            }
                            log.Trace("2.Kết thúc lưu chẩn đoán của bệnh nhân: " + objDiagInfo.MaLuotkham);
                        }
                        log.Trace("");
                        sh.Dispose();
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh chuyen vien khoi noi tru {0}", exception);
                return(ActionResult.Error);
            }
        }
예제 #14
0
        /// <summary>
        /// hàm thực hiện việc update thông tin xác nhận gói
        /// </summary>
        /// <param name="objThongtinGoiDvuBnhan"></param>
        /// <returns></returns>


        public ActionResult UpdateExamInfo(KcbChandoanKetluan objDiagInfo, KcbDangkyKcb objRegExam,
                                           KcbLuotkham objPatientExam)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {
                        if (objDiagInfo != null)
                        {
                            log.Trace("1.1 Bat dau ket thuc benh nhan: " + objDiagInfo.MaLuotkham);
                            if (objDiagInfo.IsNew)
                            {
                                //  objDiagInfo.Save();
                                SPs.SpKcbThemmoiChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdKham,
                                                                objDiagInfo.IdBenhnhan,
                                                                objDiagInfo.MaLuotkham, objDiagInfo.IdBacsikham, objDiagInfo.NgayChandoan,
                                                                objDiagInfo.NguoiTao,
                                                                objDiagInfo.NgayTao, objDiagInfo.IdKhoanoitru, objDiagInfo.IdBuonggiuong,
                                                                objDiagInfo.IdBuong, objDiagInfo.IdGiuong
                                                                , objDiagInfo.IdPhieudieutri, objDiagInfo.Noitru, objDiagInfo.IdPhongkham,
                                                                objDiagInfo.TenPhongkham, objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap
                                                                , objDiagInfo.Nhiptim, objDiagInfo.Nhiptho, objDiagInfo.Cannang,
                                                                objDiagInfo.Chieucao, objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong,
                                                                objDiagInfo.HuongDieutri, objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau
                                                                , objDiagInfo.Chandoan, objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh,
                                                                objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaytao, objDiagInfo.TenMaytao,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet
                                                                , objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt
                                                                ).Execute();
                            }
                            else
                            {
                                SPs.SpKcbCapnhatChandoanKetluan(objDiagInfo.IdChandoan, objDiagInfo.IdBacsikham,
                                                                objDiagInfo.NgayChandoan, objDiagInfo.NguoiSua, objDiagInfo.NgaySua,
                                                                objDiagInfo.IdPhieudieutri
                                                                , objDiagInfo.Noitru, objDiagInfo.IdPhongkham, objDiagInfo.TenPhongkham,
                                                                objDiagInfo.Mach, objDiagInfo.Nhietdo, objDiagInfo.Huyetap, objDiagInfo.Nhiptim,
                                                                objDiagInfo.Nhiptho, objDiagInfo.Cannang, objDiagInfo.Chieucao
                                                                , objDiagInfo.Nhommau, objDiagInfo.Ketluan, objDiagInfo.ChedoDinhduong, objDiagInfo.HuongDieutri,
                                                                objDiagInfo.SongayDieutri, objDiagInfo.TrieuchungBandau, objDiagInfo.Chandoan,
                                                                objDiagInfo.ChandoanKemtheo, objDiagInfo.MabenhChinh
                                                                , objDiagInfo.MabenhPhu, objDiagInfo.MotaBenhchinh, objDiagInfo.IpMaysua, objDiagInfo.TenMaysua,
                                                                objDiagInfo.PhanungSautiemchung, objDiagInfo.KPL1
                                                                , objDiagInfo.KPL2, objDiagInfo.KPL3, objDiagInfo.KPL4, objDiagInfo.KPL5,
                                                                objDiagInfo.KPL6, objDiagInfo.KPL7, objDiagInfo.KPL8, objDiagInfo.KL1,
                                                                objDiagInfo.KL2, objDiagInfo.KL3, objDiagInfo.KetluanNguyennhan, objDiagInfo.NhanXet,
                                                                objDiagInfo.ChongchidinhKhac, objDiagInfo.SoNgayhen, objDiagInfo.ChisoIbm, objDiagInfo.ThilucMp, objDiagInfo.ThilucMt, objDiagInfo.NhanapMp, objDiagInfo.NhanapMt).Execute();
                            }
                        }
                        log.Trace("1.2 Luu xong chan doan cua benh nhan: " + objDiagInfo.MaLuotkham);
                        SqlQuery sqlQuery = new Select().From(
                            KcbChandoanKetluan.Schema)
                                            .Where(KcbChandoanKetluan.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                                            .And(KcbChandoanKetluan.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan)
                                            .And(KcbChandoanKetluan.Columns.IdKham).IsEqualTo(objRegExam.IdKham).OrderAsc(
                            KcbChandoanKetluan.Columns.NgayChandoan);

                        KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection <KcbChandoanKetluanCollection>();

                        var query = (from chandoan in objInfoCollection.AsEnumerable()
                                     let y = Utility.sDbnull(chandoan.Chandoan)
                                             where (y != "")
                                             select y).ToArray();
                        string cdchinh = string.Join(";", query);
                        //KcbChandoanKetluanCollection objInfoCollection = sqlQuery.ExecuteAsCollection<KcbChandoanKetluanCollection>();
                        var querychandoanphu = (from chandoan in objInfoCollection.AsEnumerable()
                                                let y = Utility.sDbnull(chandoan.ChandoanKemtheo)
                                                        where (y != "")
                                                        select y).ToArray();
                        string cdphu          = string.Join(";", querychandoanphu);
                        var    querybenhchinh = (from benhchinh in objInfoCollection.AsEnumerable()
                                                 let y = Utility.sDbnull(benhchinh.MabenhChinh)
                                                         where (y != "")
                                                         select y).ToArray();
                        string mabenhchinh = string.Join(";", querybenhchinh);

                        var querybenhphu = (from benhphu in objInfoCollection.AsEnumerable()
                                            let y = Utility.sDbnull(benhphu.MabenhPhu)
                                                    where (y != "")
                                                    select y).ToArray();
                        string mabenhphu = string.Join(";", querybenhphu);
                        SPs.KcbLuotkhamTrangthaiketthuckham(objPatientExam.IdBenhnhan,
                                                            objPatientExam.MaLuotkham, objPatientExam.TrangthaiNgoaitru, objPatientExam.Noitru,
                                                            mabenhchinh, mabenhphu, objPatientExam.KetLuan, objPatientExam.HuongDieutri, cdchinh
                                                            , cdphu, objPatientExam.Locked, objPatientExam.SongayDieutri, objPatientExam.TrieuChung,
                                                            globalVariables.UserName, globalVariables.SysDate, globalVariables.gv_strIPAddress,
                                                            globalVariables.gv_strComputerName, objDiagInfo.IdBacsikham, objRegExam.TrangThai,
                                                            objRegExam.IdKham).Execute();

                        log.Trace("1.3 Update thanh cong trang thai cua benh nhan: " + objDiagInfo.MaLuotkham);

                        //new Update(KcbLuotkham.Schema)
                        //    .Set(KcbLuotkham.Columns.MabenhChinh).EqualTo(mabenhchinh)
                        //    .Set(KcbLuotkham.Columns.MabenhPhu).EqualTo(mabenhphu)
                        //    .Set(KcbLuotkham.Columns.KetLuan).EqualTo(objPatientExam.KetLuan)
                        //    .Set(KcbLuotkham.Columns.HuongDieutri).EqualTo(objPatientExam.HuongDieutri)
                        //    .Set(KcbLuotkham.Columns.ChanDoan).EqualTo(cdchinh)
                        //    .Set(KcbLuotkham.Columns.SongayDieutri).EqualTo(objPatientExam.SongayDieutri)
                        //    .Set(KcbLuotkham.Columns.ChandoanKemtheo).EqualTo(cdphu)
                        //    .Set(KcbLuotkham.Columns.TrieuChung).EqualTo(objPatientExam.TrieuChung)
                        //    .Set(KcbLuotkham.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        //    .Set(KcbLuotkham.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        //    .Set(KcbLuotkham.Columns.Locked).EqualTo(objPatientExam.Locked)
                        //    .Set(KcbLuotkham.Columns.NguoiKetthuc).EqualTo(objPatientExam.NguoiKetthuc)
                        //    .Set(KcbLuotkham.Columns.NgayKetthuc).EqualTo(objPatientExam.NgayKetthuc)
                        //    .Set(KcbLuotkham.Columns.TrangthaiNgoaitru).EqualTo(objPatientExam.TrangthaiNgoaitru)
                        //    .Where(KcbLuotkham.Columns.MaLuotkham).IsEqualTo(objPatientExam.MaLuotkham)
                        //    .And(KcbLuotkham.Columns.IdBenhnhan).IsEqualTo(objPatientExam.IdBenhnhan).Execute();
                        ////Tạm bỏ tránh việc bị cập nhật sai bác sĩ chỉ định nếu bác sĩ đó chỉ lưu thông tin kết luận
                        ////SPs.KcbThamkhamCappnhatBsyKham(Utility.Int32Dbnull(objRegExam.IdKham, -1), objPatientExam.MaLuotkham,
                        ////                            Utility.Int32Dbnull(objPatientExam.IdBenhnhan, -1),
                        ////                            Utility.Int32Dbnull(objDiagInfo.DoctorId, -1)).Execute();

                        //if (objRegExam != null)
                        //{
                        //    new Update(KcbDangkyKcb.Schema)
                        //        .Set(KcbDangkyKcb.Columns.NgaySua).EqualTo(globalVariables.SysDate)
                        //        .Set(KcbDangkyKcb.Columns.NguoiSua).EqualTo(globalVariables.UserName)
                        //        .Set(KcbDangkyKcb.Columns.IpMaysua).EqualTo(globalVariables.gv_strIPAddress)
                        //        .Set(KcbDangkyKcb.Columns.TenMaysua).EqualTo(globalVariables.gv_strComputerName)
                        //        .Set(KcbDangkyKcb.Columns.IdBacsikham).EqualTo(objDiagInfo.IdBacsikham)
                        //        .Set(KcbDangkyKcb.Columns.TrangThai).EqualTo(objRegExam.TrangThai)
                        //        .Where(KcbDangkyKcb.Columns.IdKham).IsEqualTo(Utility.Int32Dbnull(objRegExam.IdKham, -1)).
                        //        Execute();
                        //}
                        sh.Dispose();
                    }

                    scope.Complete();
                    //  Reg_ID = Utility.Int32Dbnull(objRegExam.IdKham, -1);
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh ket thuc benh nhan", exception);
                return(ActionResult.Error);
            }
        }
예제 #15
0
 protected override void CloseSession()
 {
     scope.Dispose();
 }
예제 #16
0
파일: CompanyAdsBLL.cs 프로젝트: eleooo/App
 public static bool ClickCompanyAds(SysMember user, int adsID, string answer, out string message)
 {
     SysCompanyAd item = SysCompanyAd.FetchByID(adsID);
     SysCompany company = SysCompany.FetchByID(item.AdsCompanyID);
     decimal userLastOrderSum = UserBLL.GetUserLastMonthOrderSum(user.Id);
     if (!CheckCompanyAdsCanClick(user, item, company, userLastOrderSum, out message))
         goto lbl_end;
     if (!string.IsNullOrEmpty(item.AdsQuestion) && item.AdsRightAnswer.HasValue &&
         Utilities.ToInt(answer) != item.AdsRightAnswer.Value)
     {
         message = "你的互动答题答案不正确!";
         goto lbl_end;
     }
     decimal point = CompanyAdsBLL.GetCompanyAdPoint(userLastOrderSum, item.AdsID);
     if (CompanyBLL.IsMaxPointLevel(company.Id, point))
     {
         message = "此广告主累计赠送的积分已经超过500,须进行积分结算后才能继续操作系统";
         goto lbl_end;
     }
     SysMemberAd ad = new SysMemberAd
     {
         AdsDate = DateTime.Now,
         AdsMemberID = user.Id,
         AdsPoint = point,
         CompanyID = item.AdsCompanyID,
         CompanyAdsID = item.AdsID,
         OrderSum = userLastOrderSum,
         PaymentID = 0
     };
     TransactionScope ts = new TransactionScope( );
     SharedDbConnectionScope ss = new SharedDbConnectionScope( );
     try
     {
         ad.Save( );
         item.AdsClicked = Utilities.ToInt(item.AdsClicked) + 1;
         item.AdsPointSum = Utilities.ToDecimal(item.AdsPointSum) + point;
         item.Save( );
         if (ad.AdsPoint.HasValue && ad.AdsPoint.Value > 0)
         {
             var p = new Payment
             {
                 PaymentDate = DateTime.Now,
                 PaymentCode = string.Empty,
                 PaymentCompanyID = item.AdsCompanyID,
                 PaymentEmail = string.Empty,
                 PaymentMemberID = user.Id,
                 PaymentMemo = string.Format("浏览【{0}】投放的广告,获得{1:0.00}个积分", company.CompanyName, ad.AdsPoint),
                 PaymentOrderID = ad.AdsID,
                 PaymentStatus = 1,
                 PaymentSum = ad.AdsPoint.Value,
                 PaymentType = (int)PaymentType.AdvsGive
             };
             p.Save( );
             ad.PaymentID = p.Id;
             ad.Save( );
             OrderBLL.UpdateBalance( );
         }
         ts.Complete( );
         message = string.Format("成功抢得{0}个积分", ad.AdsPoint);
         return true;
     }
     catch (Exception ex)
     {
         message = "抢积分失败:" + ex.Message;
         Logging.Log("CompanyAdsBLL->ClickCompanyAds", ex, true);
     }
     finally
     {
         ss.Dispose( );
         ts.Dispose( );
     }
     lbl_end:
     return false;
 }