Example #1
0
        /// <summary>
        /// 增加新顾客
        /// </summary>
        public int InsertCustomer(CCustomer nctm, CICCard iccd)
        {
            try
            {
                CWLocation wlctn = new CWLocation();
                CICCard    oicd  = this.SelectByUserCode(iccd.Code);

                if (oicd.CustomerID != 0 || oicd.Status == CICCard.EnmICCardStatus.Lost || oicd.Status == CICCard.EnmICCardStatus.Disposed)
                {
                    return(101); //该卡不可用
                }
                if (wlctn.SelectLctFromICCode(oicd.Code) != null)
                {
                    return(102); //该卡已用于存车
                }
                if (oicd.Type == CICCard.EnmICCardType.FixedLocation)
                {
                    if (this.FindFixICCard(oicd.Address) != null)
                    {
                        return(103); //新卡已被其车位绑定
                    }
                }

                oicd.PlatNumber = iccd.PlatNumber;  //更新
                oicd.DueDtime   = iccd.DueDtime;
                oicd.Type       = iccd.Type;
                oicd.Status     = iccd.Status;
                oicd.Address    = iccd.Address;

                CWData.myDB.InsertCustomer(nctm, oicd);

                return(100);
            }
            catch (Exception ex)
            {
                new CWSException();
                throw ex;
            }
        }
Example #2
0
        /// <summary>
        /// 更新用户信息,如果原卡号与更新卡号不一致,则释放原卡号
        /// </summary>
        public int UpdateCustomInfo(CCustomer nctm, CICCard nIccd, string oriCode)
        {
            try
            {
                CWLocation wlctn   = new CWLocation();
                CICCard    oriIccd = this.SelectByUserCode(oriCode); //原卡

                if (oriIccd.Code != nIccd.Code)                      //原卡与新卡不一致
                {
                    if (nIccd.Status == CICCard.EnmICCardStatus.Lost || nIccd.Status == CICCard.EnmICCardStatus.Disposed)
                    {
                        return(101);
                    }
                    if (nIccd.CustomerID != 0)
                    {
                        return(102); //一卡只允许一个人用
                    }
                }

                if (nIccd.Type == CICCard.EnmICCardType.FixedLocation && oriIccd.Address != nIccd.Address)  //车位不一致
                {
                    if (this.FindFixICCard(nIccd.Address) != null)
                    {
                        return(104); //新卡已被其车位绑定
                    }
                }

                if (wlctn.SelectLctFromICCode(nIccd.Code) != null)
                {
                    return(103); //该卡已存车
                }

                if (oriIccd.Code != nIccd.Code)
                {
                    //释放新卡
                    oriIccd.CustomerID = 0;
                    oriIccd.DueDtime   = CObject.DefDatetime;
                    oriIccd.Type       = CICCard.EnmICCardType.Temp;
                    oriIccd.Address    = "";
                    oriIccd.PlatNumber = "";

                    CICCard iccrd = this.SelectByUserCode(nIccd.Code);
                    iccrd = nIccd; //更新新卡号
                }
                else
                {
                    oriIccd.PlatNumber = nIccd.PlatNumber;
                    oriIccd.DueDtime   = nIccd.DueDtime;
                    oriIccd.Status     = nIccd.Status;
                    oriIccd.Type       = nIccd.Type;
                    oriIccd.Address    = nIccd.Address;
                    oriIccd.CustomerID = nIccd.CustomerID;
                }

                CWData.myDB.UpdateCustAndICcard(nctm, oriIccd, nIccd);

                return(100);
            }
            catch (Exception ex)
            {
                new CWSException();
                throw ex;
            }
        }