コード例 #1
0
        /// <summary>
        /// 查询卡信息
        /// </summary>
        /// <param name="requestData"></param>
        /// <param name="cardInfo"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public int SearchCardInfo(requestCardInfo requestData, ref CardModel cardInfo, out string message)
        {
            message = "";
            int result = 0;

            if (string.IsNullOrWhiteSpace(requestData.CardNo))
            {
                result  = 1;
                message = "参数CardNo不能为空";
                return(result);
            }

            cardInfo = new CardBLL().GetCardByCardNo(requestData.CardNo);
            if (cardInfo == null)
            {
                result  = 1;
                message = "CardNo[" + requestData.CardNo + "]不存在";
                return(result);
            }

            IThirdApp thirdApp = ThirdAppFactory.Create(Common.CommonSettings.ThirdApp);

            if (thirdApp == null)
            {
                LogHelper.Error("ThirdApp未配置");
                result  = 1;
                message = "ThirdApp未配置";
                return(result);
            }
            result = thirdApp.CardInfo(requestData, ref cardInfo, out message);
            return(result);
        }
コード例 #2
0
        public static void FindCards(string tribal = null, string name = null, bool?commander = null, string colors = null, string type = null, string tag = null, int numberToReturn = -1)
        {
            var cards = CardBLL.SearchCards(tribal, name, commander, colors, type, tag, numberToReturn);

            foreach (var card in cards)
            {
                Output.DrawCard(card);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Fronox/VisualCardsAPI
        static void Main(string[] args)
        {
            var rep     = new CardRepo();
            var cardBll = new CardBLL(rep);

            cardBll.PrintAllCards();
            var card = cardBll.GetCardById(1);

            Console.WriteLine(card.CardId + " " + card.Title + " " + card.Description);
        }
コード例 #4
0
        public ListComponent(string name, int id, CardDTO card, MoveForm move)
        {
            InitializeComponent();

            cardBLL = new CardBLL();
            listBLL = new ListBLL();

            this.nameTxt.Text = name;
            _id           = id;
            cardDTO       = card;
            this.moveForm = move;
        }
コード例 #5
0
        public void LoadCards()
        {
            this.pnLists.Controls.Clear();
            CardBLL cardBLL = new CardBLL();

            cardDTOs = cardBLL.GetAllCard(this.id);
            foreach (CardDTO card in cardDTOs)
            {
                Card cards = new Card(0, card.CardId, card.IndexCard, _listSpace);
                this.pnLists.Controls.Add(cards);
            }
        }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                LoginUser loginUser = new LoginUser(context, "CardSearch");
                CardBLL bll = new CardBLL(context, loginUser);
                if (!loginUser.Pass)//权限验证
                {
                    return;
                }

                //加载DataGrid
                if (context.Request["action"] == "gridLoad")
                {
                    int page = int.Parse(context.Request["page"]);
                    int rows = int.Parse(context.Request["rows"]);
                    string siteId = context.Request["siteId"];
                    string cardId = context.Request["cardId"];
                    string status = context.Request["status"];
                    string supplierCode = context.Request["supplierCode"];
                    string supplierBatch = context.Request["supplierBatch"];
                    bll.LoadGrid(page, rows, cardId, status, supplierCode, supplierBatch, "", siteId);
                    return;
                }
                if (context.Request["action"] == "ddlStatusListLoad")
                {
                    Combobox com = new Combobox(context, loginUser);
                    com.CardStatusCombobox();
                }
                if (context.Request["action"] == "ddlSiteListLoad")
                {
                    Combobox com = new Combobox(context, loginUser);
                    com.SiteAllCombobox();
                }
                //回收
                if (context.Request["action"] == "recycle")
                {
                    string startCardId = context.Request["startCardId"];//起始卡号
                    string endCardId = context.Request["endCardId"];//结束卡号
                    int cardNum = int.Parse(context.Request["cardNum"]);//卡片数量
                    bll.Recycle(startCardId, endCardId, cardNum);
                    return;
                }
            }
            catch (Exception e)
            {
                Message.error(context, e.Message);
            }
        }
コード例 #7
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(tbTitleNewCard.Text))
     {
         MessageBox.Show("Please enter title before add card", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     else
     {
         CardBLL cardBLL = new CardBLL();
         CardDTO cardDTO = new CardDTO(cardBLL.GetAllCard().Count() + 1, this.id, cardDTOs.Count() + 1, tbTitleNewCard.Text, "", 1, DateTime.MinValue, 0);
         cardBLL.InsertCard(cardDTO);
     }
     LoadCards();
 }
コード例 #8
0
        public int CreateCard(CardBLL cardBLL)
        {
            if (cardBLL == null)
            {
                throw new Exception("Error. card == null");
            }

            var card = new Card()
            {
                Text = cardBLL.Text, IdList = cardBLL.List
            };

            Database.Cards.Create(card);
            Database.Save();
            return(card.Id);
        }
コード例 #9
0
        public void UpdateCard(CardBLL cardBLL)
        {
            if (cardBLL == null)
            {
                throw new Exception("error. update card bll");
            }

            Card card = new Card()
            {
                Id     = cardBLL.Id,
                IdList = cardBLL.List,
                Text   = cardBLL.Text
            };

            Database.Cards.Update(card);
            Database.Save();
        }
コード例 #10
0
        public IActionResult PostCard([FromBody] CardBLL card)
        {
            try
            {
                if (card.Text == "")
                {
                    throw new Exception("Error. Card in request is null");
                }

                card.Id = cardService.CreateCard(card);

                return(Ok(card));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #11
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                LoginUser loginUser = new LoginUser(context, "CardGrant");
                CardBLL   bll       = new CardBLL(context, loginUser);
                SiteBLL   siteBll   = new SiteBLL(context, loginUser);
                if (!loginUser.Pass)//权限验证
                {
                    return;
                }

                //加载DataGrid
                if (context.Request["action"] == "gridLoad")
                {
                    int    page     = int.Parse(context.Request["page"]);
                    int    rows     = int.Parse(context.Request["rows"]);
                    string siteId   = context.Request["siteId"];
                    string siteName = context.Request["siteName"];
                    siteBll.LoadGrid(page, rows, siteId, siteName, ((int)AuditStauts.AuditSucces).ToString());
                    return;
                }
                if (context.Request["action"] == "load")
                {
                    //加载信息
                    siteBll.Load(context.Request["siteId"]);
                }
                //发放
                if (context.Request["action"] == "add")
                {
                    string siteId      = context.Request["siteId"];             //快开厅编号
                    string startCardId = context.Request["startCardId"];        //起始卡号
                    string endCardId   = context.Request["endCardId"];          //结束卡号
                    int    cardNum     = int.Parse(context.Request["cardNum"]); //卡片数量
                    bll.Grant(startCardId, endCardId, cardNum, siteId);
                    return;
                }
            }
            catch (Exception e)
            {
                Message.error(context, e.Message);
            }
        }
コード例 #12
0
        //根据结算方式编号获取卡实体
        public PayedCard(string jsfsbh)
        {
            Card        mCard = new Card();
            List <Card> list  = new CardBLL().GetCards();

            mCard = list.Where(o => o.jsfsbh == jsfsbh).FirstOrDefault();

            if (mCard != null)
            {
                this.id     = mCard.id;
                this.card   = mCard.card;
                this.jsfsbh = mCard.jsfsbh;
                this.State  = mCard.State;
                this.ksrq   = mCard.ksrq;
            }
            else
            {
                MessageBox.Show("结算方式编号不正确,没有查到实体卡");
            }
        }
コード例 #13
0
        public List <CardBLL> GetCards(int listId)
        {
            var cards    = Database.Cards.GetAll().Where(x => x.IdList == listId);
            var cardsBLL = new List <CardBLL>();

            if (cards == null)
            {
                throw new Exception("Error create list of cards");
            }

            foreach (var c in cards)
            {
                var cardBLL = new CardBLL()
                {
                    Id = c.Id, List = c.IdList, Text = c.Text
                };

                cardsBLL.Add(cardBLL);
            }

            return(cardsBLL);
        }
コード例 #14
0
        public CardBLL GetCard(int id)
        {
            if (id == 0)
            {
                throw new Exception("id == null");
            }

            var card = Database.Cards.Get(id);

            if (card == null)
            {
                throw new Exception("card don't find");
            }

            CardBLL cardBLL = new CardBLL()
            {
                Id   = card.Id,
                List = card.IdList,
                Text = card.Text
            };

            return(cardBLL);
        }
コード例 #15
0
        public IActionResult PutCard([FromBody] CardBLL card)
        {
            try
            {
                if (card == null)
                {
                    throw new Exception("Error. Card in request is null");
                }

                if (cardService.GetCard(card.Id) == null)
                {
                    throw new Exception("Error. Card not found");
                }

                cardService.UpdateCard(card);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #16
0
        /// <summary>
        /// 读取数据
        /// </summary>
        private void GetData()
        {
            Thread.Sleep(1000);

            #region 更新主档信息
            //商品主档和商品变化主档同时存在时,先读取商品主档,再读取变化主档
            if (File.Exists(GlobalParams.spmxServerPath))
            {
                int ret;
                ret = new GoodsBLL().DeleteGoods();

                if (ret >= 0)
                {
                    DataOperator.UpdateData(GlobalParams.spmxServerPath, GlobalParams.spmxLocalPath, "goods_spmx", false);
                }
                else
                {
                    MessageBox.Show("商品表更新异常,请重新登录");
                    Log.WriteErrorLog("清空商品表出现异常,中断更新");
                }
            }
            DataOperator.UpdateSpit();

            if (File.Exists(GlobalParams.ygkServerPath))
            {
                int ret;
                ret = new StaffBLL().DeleteStaff();

                if (ret >= 0)
                {
                    DataOperator.UpdateData(GlobalParams.ygkServerPath, GlobalParams.ygkLocalPath, "staff_ygk", false);
                }
                else
                {
                    MessageBox.Show("员工表更新异常,请重新登录");
                    Log.WriteErrorLog("清空员工表出现异常,中断更新");
                }
            }

            if (File.Exists(GlobalParams.jsfsServerPath))
            {
                int ret;
                ret = new CardBLL().DeleteCard();

                if (ret >= 0)
                {
                    DataOperator.UpdateData(GlobalParams.jsfsServerPath, GlobalParams.jsfsLocalPath, "paymentmethod_jsfs", false);
                }
                else
                {
                    MessageBox.Show("结算方式表更新异常,请重新登录");
                    Log.WriteErrorLog("清空结算方式表出现异常,中断更新");
                }
            }

            if (File.Exists(GlobalParams.yhxsServerPath))
            {
                int ret;
                ret = new DiscountBLL().DeleteDiscount();

                if (ret >= 0)
                {
                    DataOperator.UpdateData(GlobalParams.yhxsServerPath, GlobalParams.yhxsLocalPath, "discount_yhxs", false);
                }
                else
                {
                    MessageBox.Show("时段折扣表更新异常,请重新登录");
                    Log.WriteErrorLog("清空时段折扣表出现异常,中断更新");
                }
            }

            //促销没有主键,采用先清空,再导入的策略
            if (File.Exists(GlobalParams.ptServerPath))
            {
                int ret;
                ret = new PromotionBLL().DeletePromotion();

                if (ret >= 0)
                {
                    DataOperator.UpdateData(GlobalParams.ptServerPath, GlobalParams.ptLocalPath, "promotion_pt", false);
                }
                else
                {
                    MessageBox.Show("促销表更新异常,请重新登录");
                    Log.WriteErrorLog("清空促销表出现异常,中断更新");
                }
            }
            #endregion

            Staff loginStaff = new StaffBLL().GetStaffByID(txtStaffID.Text);

            //记录登录的员工
            staff = loginStaff;
        }
コード例 #17
0
        /// <summary>
        /// 卡充值退款操作
        /// </summary>
        /// <param name="requestData"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public int CardChargeOpr(requestCardCharge requestData, out string message)
        {
            message = "";
            int result = 0;

            if (string.IsNullOrWhiteSpace(requestData.CardNo))
            {
                result  = 1;
                message = "参数CardNo不能为空";
                return(result);
            }

            CardModel cardModel = new CardBLL().GetCardByCardNo(requestData.CardNo);

            if (cardModel == null)
            {
                result  = 1;
                message = "CardNo[" + requestData.CardNo + "]不存在或已删除";
                return(result);
            }

            int OprType = requestData.OprType;

            IThirdApp thirdApp = ThirdAppFactory.Create(Common.CommonSettings.ThirdApp);

            if (thirdApp == null)
            {
                LogHelper.Error("ThirdApp未配置");
            }

            switch (OprType)
            {
            case 1:     //充值
                CardChargeModel chargeModel = new CardChargeModel();
                chargeModel.CardNo = cardModel.CardNo;
                float balance  = 0;
                float oprmoney = 0;
                float.TryParse(cardModel.Balance, out balance);
                float.TryParse(requestData.OprMoney, out oprmoney);

                chargeModel.AfterMoney = (balance + oprmoney).ToString();
                chargeModel.OprMoney   = requestData.OprMoney;
                chargeModel.OprType    = 1;
                chargeModel.PreMoney   = cardModel.Balance;
                chargeModel.Remark     = requestData.Remark;

                result = thirdApp.CardChargeOpr(chargeModel, OprType, out message);
                if (result == 0)
                {
                    new CardChargeBLL().Insert(chargeModel);

                    cardModel.Balance = chargeModel.AfterMoney;
                    new CardBLL().Update(cardModel);
                }


                break;

            case 2:     //退款
                CardChargeModel chargeModel2 = new CardChargeModel();
                chargeModel2.CardNo = cardModel.CardNo;
                float balance2  = 0;
                float oprmoney2 = 0;
                float.TryParse(cardModel.Balance, out balance2);
                float.TryParse(requestData.OprMoney, out oprmoney2);

                chargeModel2.AfterMoney = (balance2 - oprmoney2).ToString();
                chargeModel2.OprMoney   = requestData.OprMoney;
                chargeModel2.OprType    = 2;
                chargeModel2.PreMoney   = cardModel.Balance;
                chargeModel2.Remark     = requestData.Remark;

                result = thirdApp.CardChargeOpr(chargeModel2, OprType, out message);
                if (result == 0)
                {
                    new CardChargeBLL().Insert(chargeModel2);
                    cardModel.Balance = chargeModel2.AfterMoney;
                    new CardBLL().Update(cardModel);
                }
                break;

            default:
                break;
            }



            return(result);
        }
コード例 #18
0
        /// <summary>
        /// 卡操作
        /// </summary>
        /// <param name="requestData"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public int CardOpr(requestCardOpr requestData, out string message)
        {
            message = "";
            int result = 0;

            if (string.IsNullOrWhiteSpace(requestData.CardNo))
            {
                result  = 1;
                message = "参数CardNo不能为空";
                return(result);
            }

            if (string.IsNullOrWhiteSpace(requestData.PersonId))
            {
                //result = 1;
                //message = "参数PersonId不能为空";
                requestData.PersonId = requestData.CardNo.Trim();
                LogHelper.Info("卡操作:传递的参数PersonID为空。使用CardNo进行人事登记");
                //return result;
            }
            string deptId = "00000000-0000-0000-0000-000000000000";

            if (!string.IsNullOrWhiteSpace(requestData.DeptId))
            {
                deptId = requestData.DeptId.Trim();
            }


            DepartmentModel depart = null;
            PersonBLL       bll    = new PersonBLL();
            PersonModel     person = bll.GetPersonByPersonId(requestData.PersonId);

            if (person == null)
            {
                //创建部门和人事资料

                PersonModel requestPerson = new PersonModel();
                requestPerson.PersonName = string.IsNullOrWhiteSpace(requestData.PersonName) ? requestData.PersonId : requestData.PersonName;
                requestPerson.PersonId   = requestData.PersonId;
                requestPerson.DeptId     = deptId;
                DepartmentModel requestDetp = new DepartmentModel();
                requestDetp.DeptId = deptId;
                depart             = new DepartmentBLL().GetDepartmentByDeptId(requestDetp.DeptId);
                if (depart == null)
                {
                    requestDetp.DeptName = string.IsNullOrWhiteSpace(requestData.DeptName) ? "默认部门" : requestData.DeptName;
                    requestDetp.DeptNo   = deptId;
                    result = DeptOpr(requestDetp, out message);
                    if (result != 0)
                    {
                        return(result);
                    }
                    depart = requestDetp;
                }
                result = PersonOpr(requestPerson, out message);
                if (result != 0)
                {
                    return(result);
                }
                person = requestPerson;
            }
            if (depart == null)
            {
                depart = new DepartmentBLL().GetDepartmentByDeptId(person.DeptId);
            }
            int OprType = 0;//1:新增发行, 2:退卡, 3:挂失,4,更新

            if (requestData.Status == 1)
            {
                OprType = 2;//退卡
            }
            else if (requestData.Status == 2)
            {
                OprType = 3;//挂失
            }

            CardModel cardModel = new CardBLL().GetCardByCardNo(requestData.CardNo);

            if (OprType == 2)
            {
                if (cardModel == null)
                {
                    result = 0;
                    return(result);
                }
            }
            if (OprType == 3)
            {
                if (cardModel == null)
                {
                    result  = 1;
                    message = "CardNo[" + requestData.CardNo + "]不存在或已删除";
                    return(result);
                }
            }
            if (cardModel == null)
            {
                OprType             = OprType == 0 ? 1 : OprType;
                cardModel           = new CardModel();//发行
                cardModel.BackMoney = "";
                cardModel.Balance   = "0";
                cardModel.BeginTime = requestData.BeginTime;
                cardModel.CardCost  = requestData.CardCost;
                cardModel.CardNo    = requestData.CardNo;
                cardModel.EndTime   = requestData.EndTime;
                cardModel.PersonId  = requestData.PersonId;
                cardModel.Status    = requestData.Status;
            }
            else
            {
                OprType = OprType == 0 ? 4 : OprType;//更新
                if (((DateTime)requestData.BeginTime).Year > 2000)
                {
                    cardModel.BeginTime = requestData.BeginTime;
                }

                if (((DateTime)requestData.EndTime).Year > 2000)
                {
                    cardModel.EndTime = requestData.EndTime;
                }

                cardModel.PersonId = requestData.PersonId;
                cardModel.Status   = requestData.Status;
                cardModel.CardCost = requestData.CardCost;
            }
            if (OprType != 1)
            {
                if (cardModel == null)
                {
                    result  = 1;
                    message = "CardNo[" + requestData.CardNo + "]不存在或已删除";
                    return(result);
                }
            }
            IThirdApp thirdApp = ThirdAppFactory.Create(Common.CommonSettings.ThirdApp);

            if (thirdApp != null)
            {
                thirdApp.CardOpr(cardModel, person, depart, OprType, out message);
            }

            switch (OprType)
            {
            case 1:     //新增
                new CardBLL().Insert(cardModel);
                break;

            case 2:     //退卡
                //float balance = 0;
                //float backmoney = 0;
                //float.TryParse(cardModel.Balance, out balance);
                //float.TryParse(cardModel.BackMoney, out backmoney);
                cardModel.Balance = "0";
                new CardBLL().Delete(cardModel);

                CardChargeModel chargeModel = new CardChargeModel();
                chargeModel.CardNo     = cardModel.CardNo;
                chargeModel.AfterMoney = "0";
                chargeModel.OprMoney   = cardModel.Balance;
                chargeModel.OprType    = 2;
                chargeModel.PreMoney   = cardModel.Balance;
                chargeModel.Remark     = "退卡注销金额清为0,注销金额" + cardModel.Balance;

                new CardChargeBLL().Insert(chargeModel);;
                break;

            case 3:     //挂失
                requestData.Status = 2;
                new CardBLL().Update(cardModel);
                break;

            case 4:     //更新
                new CardBLL().Update(cardModel);
                break;

            default:
                break;
            }


            return(result);
        }