Exemple #1
0
        /// <summary>
        /// Method use to validate at beginning of Introduce friend.
        /// </summary>
        /// <returns></returns>
        public string IntroduceFriendValidation(string strMembershipID, bool hasIntroRight)
        {
            TblMember sqlMember = new TblMember();

            sqlMember.StrMembershipID = strMembershipID;
            DataTable myTable = sqlMember.SelectOne();

            sqlMember.Dispose();

            if (ACMS.Convert.ToDateTime(myTable.Rows[0]["dtSignupDate"]).Date !=
                DateTime.Now.Date)
            {
                if (!hasIntroRight)
                {
                    return("This member is not signup today. Therefore, can't introduce by anyone.");
                }
            }

            if (myTable.Rows[0]["strIntroducerMembershipID"] != DBNull.Value)
            {
                return("This member already been introduced.");
            }

            return("");
        }
Exemple #2
0
        public static bool MembershipIDExist(string strMembershipID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();

                return(sqlMember.MembershipIDExists(strMembershipID));
            }
            finally
            {
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
            }
        }
Exemple #3
0
        protected void SendConfirmation(string strMembershipID, string strMembershipName, string strEmail)
        {
            int    nEdmId = 71;
            string tmp_strEncryptionKey = "";
            string tmp_strSubject       = "";
            string tmp_strContent       = "";
            string tmp_strSender        = "";
            Random rnd = new Random();

            DateTime dtToday      = DateTime.Today;
            string   dtExpiryDate = String.Format("{0:MMM d, yyyy}", dtToday.AddMonths(1));

            //Blast the email consent to the leads if email is not null
            if (strEmail.Trim() != "" && IsEmailValid(strEmail.ToLower()))
            {
                DataTable dtEdmContent = new DataTable();
                TblMember myMember     = new TblMember();
                dtEdmContent = myMember.GetMemberConfirmationEmail();

                if (dtEdmContent.Rows.Count > 0)
                {
                    foreach (DataRow rs in dtEdmContent.Rows)
                    {
                        tmp_strSender  = rs["strSender"].ToString().Trim();
                        tmp_strSubject = rs["strSubject"].ToString().Trim();
                        tmp_strContent = rs["strContent"].ToString().Trim();
                    }
                }

                dtEdmContent.Dispose();
                //nEdmId = myContacts.CreateNewEdm(tmp_strSender, tmp_strSubject, tmp_strContent, 1, 9, "L"); //Insert Into DB

                string tmp_strMembershipID = strMembershipID.ToString();
                string tmp_strMemberName   = strMembershipName;
                //Generate random order number 1-5
                int    tmp_nOrder  = GetRandomOrderNo(rnd);
                string tmp_strDate = GetToday();

                //Generate Encryption Key, status = 0
                tmp_strEncryptionKey = GetEncryptionKey(nEdmId, tmp_strMembershipID, strEmail.Trim(), tmp_strDate);

                //Need to check if email has been sent - from logs
                if (!IsDuplicatedSubmission(tmp_strMembershipID,
                                            strEmail.Trim(),
                                            nEdmId,
                                            tmp_strEncryptionKey))
                {
                    //Send Email
                    SendEDM(StrMembershipID, tmp_strMemberName.ToUpper(), dtExpiryDate, strEmail,
                            tmp_strSender, tmp_strSubject, tmp_strContent, nEdmId.ToString(),
                            tmp_strEncryptionKey);

                    InsertEmailSendingLog(strEmail.Trim(), nEdmId,
                                          tmp_strMembershipID, tmp_strMemberName,
                                          tmp_strDate, tmp_strEncryptionKey,
                                          "M");
                    MessageBox.Show("Email sent");
                }
            }
        }
Exemple #4
0
        public bool Reprint(string strMembershipID, int nEmployee, int CardStatus, string strCardBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember      sqlMember      = new TblMember();
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit       sqlAudit       = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider      = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider       = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ReprintCard");

                sqlMember.UpdateCardStatus(strMembershipID, CardStatus, strCardBranchCode);
                sqlCardRequest.NEmployeeID     = nEmployee;
                sqlCardRequest.NStatusID       = CardStatus;
                sqlCardRequest.StrBranchCode   = strCardBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate  = DateTime.Now;
                sqlCardRequest.Insert();

                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID   = nEmployee;
                sqlAudit.StrAuditEntry = "Reprint member card.";
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ReprintCard");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
                sqlCardRequest.Dispose();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }
Exemple #5
0
        public IActionResult Index()
        {
            List <TblCart> cart = dop.TblCarts.Where(x => x.OrderId == null).ToList();
            TblMember      user = SessionHelper.GetObjectFromJson <TblMember>(HttpContext.Session, "user");

            if (user != null)
            {
                cart = cart.Where(x => x.MemberId == user.MemberId).ToList();
            }
            else
            {
                cart = cart.Where(x => x.MemberId == null).ToList();
            }

            ViewBag.cart = cart;
            if (cart.Count != 0)
            {
                ViewBag.total = cart.Sum(item => item.GetProduct().Price *item.Quantity);
            }
            else
            {
                return(Redirect("/"));
            }
            return(View());
        }
Exemple #6
0
 public DataTable GetMemberBooking(string strMembershipID)
 {
     if (myMember == null)
     {
         myMember = new TblMember();
     }
     return(myMember.GetMemberBooking(strMembershipID));
 }
Exemple #7
0
        public MemberRecord(string aBranchCode)
        {
            myCurrentBranch = aBranchCode;
            myMember        = new TblMember();
            InitLookupEdit();

            dtblPreset = myMember.SelectLast15(myCurrentBranch);
        }
Exemple #8
0
 public ActionResult MemberAdd(TblMember p)
 {
     if (!ModelState.IsValid)
     {
         return(View("MemberAdd"));
     }
     db.TblMember.Add(p);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemple #9
0
        public IActionResult AddAddressSuccess()
        {
            TblMember         user     = SessionHelper.GetObjectFromJson <TblMember>(HttpContext.Session, "user");
            List <TblCart>    cart     = dop.TblCarts.ToList().Where(x => x.MemberId == user.MemberId && x.OrderId == SessionHelper.GetObjectFromJson <long>(HttpContext.Session, "order_id")).ToList();
            TblShippingDetail shipping = dop.TblShippingDetails.FirstOrDefault(x => x.OrderId == SessionHelper.GetObjectFromJson <long>(HttpContext.Session, "order_id"));

            ViewBag.shipping = shipping;
            ViewBag.cart     = cart;
            ViewBag.total    = cart.Sum(item => item.GetProduct().Price *item.Quantity);
            return(View());
        }
Exemple #10
0
        public async Task <IActionResult> Register(TblMember tblMember)
        {
            if (ModelState.IsValid)
            {
                dop.Add(tblMember);
                await dop.SaveChangesAsync();

                return(Redirect("/"));
            }
            return(View(tblMember));
        }
Exemple #11
0
        public async Task <IActionResult> Buy(int id)
        {
            // TODO :: apply user to cart if login success
            TblMember user     = SessionHelper.GetObjectFromJson <TblMember>(HttpContext.Session, "user");
            TblCart   cartExit = dop.TblCarts.Where(x => x.ProductId == id && x.OrderId == null).FirstOrDefault();

            if (cartExit == null)
            {
                TblCart tblCart = new TblCart();
                tblCart.ProductId = id;
                tblCart.Quantity  = 1;
                if (user != null)
                {
                    tblCart.MemberId = user.MemberId;
                }

                //tblCart.Product = productModel.find(id);
                dop.Add(tblCart);
                await dop.SaveChangesAsync();
            }

            /*ProductModel productModel = new ProductModel();
             * if(SessionHelper.GetObjectFromJson<List<TblProduct>>(HttpContext.Session,"cart")==null)
             * {
             *      List<TblProduct> cart = new List<TblProduct>();
             *      var product = productModel.find(id);
             *      product.Quantity = 1;
             *      cart.Add(product);
             *
             *      dop.Add(new TblCart(cart));
             *
             *      SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
             * }
             * else
             * {
             *      List<TblProduct> cart = SessionHelper.GetObjectFromJson<List<TblProduct>>(HttpContext.Session, "cart");
             *      int index = isExit(id);
             *      if(index != -1)
             *      {
             *              cart[index].Quantity++;
             *      }
             *      else
             *      {
             *              var product = productModel.find(id);
             *              product.Quantity = 1;
             *              cart.Add(product);
             *      }
             *      SessionHelper.SetObjectAsJson(HttpContext.Session, "cart", cart);
             * }*/


            return(Redirect("/Cart"));
        }
Exemple #12
0
        public IActionResult AddShipping()
        {
            TblMember user = SessionHelper.GetObjectFromJson <TblMember>(HttpContext.Session, "user");

            SessionHelper.SetObjectAsJson(HttpContext.Session, "order_id", DateTimeOffset.Now.ToUnixTimeSeconds());

            TblShippingDetail address = new TblShippingDetail();

            address.MemberId = user.MemberId;
            address.OrderId  = SessionHelper.GetObjectFromJson <long>(HttpContext.Session, "order_id");
            ViewBag.address  = address;
            return(View());
        }
Exemple #13
0
        public bool Delete(string strMembershipID, User aUser, string strRemark)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblAudit  sqlAudit  = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider  = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("DeleteMember");

                sqlMember.DeleteMember(strMembershipID, strRemark);
                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Delete member " + strMembershipID;
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("DeleteMember");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }
Exemple #14
0
        public ActionResult MemberUpdate(TblMember p)
        {
            var member = db.TblMember.Find(p.ID);

            member.Name     = p.Name;
            member.Surname  = p.Surname;
            member.Mail     = p.Mail;
            member.Username = p.Username;
            member.Password = p.Password;
            member.PhotoURL = p.PhotoURL;
            member.Phone    = p.Phone;
            member.School   = p.School;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #15
0
        public async Task <IActionResult> AddShipping(TblShippingDetail tblShippingDetail)
        {
            if (ModelState.IsValid)
            {
                TblMember      user = SessionHelper.GetObjectFromJson <TblMember>(HttpContext.Session, "user");
                List <TblCart> cart = dop.TblCarts.ToList().Where(x => x.MemberId == user.MemberId && x.OrderId == null).ToList();
                ViewBag.total = cart.Sum(item => item.GetProduct().Price *item.Quantity);
                dop.Add(tblShippingDetail);
                cart.ForEach(x => x.OrderId = tblShippingDetail.OrderId);

                await dop.SaveChangesAsync();

                return(RedirectToAction("AddAddressSuccess"));
            }
            return(View(tblShippingDetail));
        }
Exemple #16
0
        //Amended by TBBC on 22 September 2015 for Intro friend package.
        public bool SaveIntroduceFriendforPackage(string strMembershipID, string strIntroducerID, string strPromotionCode, int employeeID)
        {
            bool bolReturn = false;

            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveIntroduceFriendforPackage");

                //sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);
                DataTable IntroFriendFreebieTable = sqlMember.AddIntroFriendPackage(strIntroducerID, "INTRO " + strMembershipID, strPromotionCode, employeeID);

                //if (IntroFriendFreebieTable.Rows.Count > 0)
                //{
                //    bolReturn = true;
                //}
                connProvider.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                //sqlRewardsTransaction.Dispose();
                sqlMember.Dispose();
            }
        }
Exemple #17
0
        //2006

        // public DataTable SaveIntroduceFriendNew(string strMembershipID, string strIntroducerID, string strPackage, string strRemark, int employeeID)


        public bool SaveIntroduceFriendNew(string strMembershipID, string strIntroducerID, string strPackage, string strRemark, int employeeID, int nPackageID)

        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember        sqlMember        = new TblMember();
            TblMemberPackage sqlMemberPackage = new TblMemberPackage();
            TblPackage       sqlPackage       = new TblPackage();

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveIntroduceFriend");

                //  sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);
                sqlMember.UpdateIntroducerMembershipID(strIntroducerID, strMembershipID);
                MemberPackage.CreateFreeMemberSpaPackage_IntroFriend(strMembershipID, strPackage, strRemark, ref nPackageID);
                // MemberPackage.CreateFreeMemberSpaPackage_IntroFriend(strIntroducerID, strPackage, strRemark, ref nPackageID);

                connProvider.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlPackage.Dispose();
                sqlMember.Dispose();
            }
        }
Exemple #18
0
        public DataTable SaveIntroduceFriend(string strMembershipID, string strIntroducerID, string Freebie, string strBranchCode, int employeeID)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveIntroduceFriend");

                sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);
                DataTable IntroFriendFreebieTable = sqlMember.AddIntroFriendFreebie(strMembershipID, strIntroducerID, Freebie, strBranchCode, employeeID);

                connProvider.CommitTransaction();
                return(IntroFriendFreebieTable);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                //sqlRewardsTransaction.Dispose();
                sqlMember.Dispose();
            }
        }
Exemple #19
0
        private void sbtnIntroduce_Click(object sender, System.EventArgs e)
        {
            //0506
            if ((lkpEdtLoyalPoint.EditValue != null || lkFreebie.EditValue != null || lkTreatment.EditValue != null) && ucMemberID1.EditValue.ToString().Length != 0)
            {
                if (string.Compare(strMembershipID.Trim(), ucMemberID1.EditValue.ToString().Trim(), true) == 0)
                {
                    UI.ShowErrorMessage(this, "Member introduce him/herself is not allow.");
                    ucMemberID1.Focus();
                    DialogResult = DialogResult.None;
                    return;
                }

                TblMember sqlMember = new TblMember();
                sqlMember.StrMembershipID = ucMemberID1.EditValue.ToString();
                DataTable memberTable = sqlMember.SelectOne();

                if (memberTable.Rows.Count > 0)
                {
                    if (string.Compare(memberTable.Rows[0]["strIntroducerMembershipID"].ToString().Trim(), strMembershipID.Trim(), true) == 0)
                    {
                        UI.ShowErrorMessage(this, "Introducer selected was introduced by this member.");
                        ucMemberID1.Focus();
                        DialogResult = DialogResult.None;
                        return;
                    }
                }

                string PointType = lkpEdtLoyalPoint.Text;

                double point          = 0.0;
                string promoteFreebie = "";
                if (lkpEdtLoyalPoint.EditValue != null)
                {
                    point = System.Convert.ToDouble(lkpEdtLoyalPoint.EditValue);
                }

                else if (lkFreebie.EditValue != null)
                {
                    promoteFreebie = lkFreebie.EditValue.ToString();
                }
                else if (lkTreatment.EditValue != null)
                {
                    promoteFreebie = lkTreatment.EditValue.ToString();
                }

                string introducerID = ucMemberID1.EditValue.ToString();

                if (point > 0)
                {
                    if (myMemberRecord.SaveIntroduceFriend(strMembershipID, introducerID, point, employeeID))
                    {
                        this.DialogResult = DialogResult.OK;
                        PrintIntroReceipt(strMembershipID, introducerID, point, PointType);
                    }
                }                //0506
                else if (lkTreatment.EditValue != null)
                {
                    bool success = false;
                    //success = myMemberRecord.SaveIntroduceFriendNew(strMembershipID, introducerID, "BM004(58)", "INTRO " + introducerID, employeeID, 0);
                    //Amended by TBBC on 22 September 2015 for Intro friend package.
                    //success = myMemberRecord.SaveIntroduceFriendNew( introducerID,strMembershipID, "BM004(58)", "INTRO " + strMembershipID, employeeID, 0);
                    success = myMemberRecord.SaveIntroduceFriend(strMembershipID, introducerID, 0, employeeID);
                    success = myMemberRecord.SaveIntroduceFriendforPackage(strMembershipID, introducerID, lkTreatment.EditValue.ToString(), employeeID);

                    if (success)
                    {
                        this.DialogResult = DialogResult.OK;
                        //PrintIntroReceipt(strMembershipID, introducerID, PrintIntroReceiptServices);
                        PrintIntroReceiptServices(strMembershipID, introducerID, lkTreatment.Text);
                    }
                }
                else if (promoteFreebie != "")
                {
                    DataTable IntroFriendFreebie = myMemberRecord.SaveIntroduceFriend(strMembershipID, introducerID, promoteFreebie, User.BranchCode, employeeID);
                    if (IntroFriendFreebie.Rows.Count > 0)
                    {
                        this.DialogResult = DialogResult.OK;
                        PrintIntroReceipt(strMembershipID, introducerID, IntroFriendFreebie);
                    }
                }
            }
            else
            {
                ACMS.Utils.UI.ShowErrorMessage(this, "Please fill in all field.", "Error");
                lkpEdtLoyalPoint.Focus();
                DialogResult = DialogResult.None;
            }
        }
Exemple #20
0
        public bool UpdateCardStatus(string strMembershipID, User aUser, CardStatusType myType, int nRequestID,
                                     string strBranchCode)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember      sqlMember      = new TblMember();
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit       sqlAudit       = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider      = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider       = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ChangeCardStatus");

                if (CardStatusType.RequestPrint == myType)
                {
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, "HQ");
                }
                else
                {
                    sqlMember.UpdateCardStatus(strMembershipID, (int)myType, strBranchCode);
                }
                sqlCardRequest.NEmployeeID     = aUser.NEmployeeID();
                sqlCardRequest.NRequestID      = nRequestID;
                sqlCardRequest.NStatusID       = (int)myType;
                sqlCardRequest.StrBranchCode   = strBranchCode;
                sqlCardRequest.StrMembershipID = strMembershipID;
                sqlCardRequest.DtLastEditDate  = DateTime.Now;
                sqlCardRequest.Update();

                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberCard;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member card to " + myType.ToString() + ".";
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ChangeCardStatus");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
                sqlCardRequest.Dispose();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }
Exemple #21
0
        public bool SaveIntroduceFriend(string strMembershipID, string strIntroducerID, double point, int employeeID)
        {
            ACMSDAL.ConnectionProvider connProvider     = new ConnectionProvider();
            TblMember             sqlMember             = new TblMember();
            TblRewardsTransaction sqlRewardsTransaction = new TblRewardsTransaction();

            try
            {
                sqlRewardsTransaction.MainConnectionProvider = connProvider;
                sqlMember.MainConnectionProvider             = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("SaveIntroduceFriend");

                sqlMember.UpdateIntroducerMembershipID(strMembershipID, strIntroducerID);

                sqlRewardsTransaction.DRewardsPoints  = point;
                sqlRewardsTransaction.DtDate          = DateTime.Now;
                sqlRewardsTransaction.NEmployeeID     = employeeID;
                sqlRewardsTransaction.NTypeID         = 0;
                sqlRewardsTransaction.StrMembershipID = strIntroducerID;
                sqlRewardsTransaction.StrReferenceNo  = strMembershipID;
                sqlRewardsTransaction.Insert();

                for (int i = 0; i < 5; i++)
                {
                    sqlMember.InsertFWFChance(strIntroducerID);
                }

                connProvider.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                connProvider.RollbackTransaction("SaveIntroduceFriend");
                if (ex.InnerException.Message.IndexOf("FK_tblMember_tblMember") >= 0 ||
                    ex.Message.IndexOf("FK_tblMember_tblMember") >= 0 ||
                    ex.InnerException.Message.IndexOf("FK_tblRewardsTransaction_tblMember") >= 0 ||
                    ex.Message.IndexOf("FK_tblRewardsTransaction_tblMember") >= 0)
                {
                    ACMS.Utils.UI.ShowErrorMessage(null, "Please enter a valid Membership ID.", "Error");
                    return(false);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlRewardsTransaction.Dispose();
                sqlMember.Dispose();
            }
        }
Exemple #22
0
 public MemberRecord(string strMembershipID, string strBranchCode)
 {
     myMember   = new TblMember();
     dtblPreset = myMember.SelectFixedOne(strMembershipID, strBranchCode);
 }
Exemple #23
0
        private void simpleButtonOK_Click(object sender, System.EventArgs e)
        {
            DataRow r = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (r != null)
            {
                ACMSDAL.TblMemberPackage sqlCalcAnyOS1 = new ACMSDAL.TblMemberPackage();
                decimal dOutAmount = sqlCalcAnyOS1.OutstandingAmount(myPOS.StrMembershipID);

                if (myPOS.ReceiptMasterTable.Rows[0]["nCategoryID"].ToString() == "9")
                {
                    if (myPOS.ReceiptItemsTable.Select("strCode='" + r["strPackageGroupCode"].ToString() + "'").Length > 0)
                    {
                        MessageBox.Show(this, r["strPackageGroupCode"].ToString() + " already selected!", "Warning");
                        return;
                    }
                }

                if (dOutAmount > 0)
                {
                    DialogResult result1 = MessageBox.Show(this, myPOS.ReceiptMasterTable.Rows[0]["strMemberName"] + " has Outstanding amount of " + (string.Format("{0:C}", dOutAmount)) + "\nDo you want to continue?", "Warning",
                                                           MessageBoxButtons.YesNo);

                    if (result1 == DialogResult.No)
                    {
                        return;
                    }
                }

                if (myCategoryID == 4)
                {
                    //2106
                    TblMember sqlMember = new TblMember();
                    if (sqlMember.MembershipThisMonthBirtdayForUtilised(myPOS.StrMembershipID))
                    {
                        DialogResult result1 = MessageBox.Show("Member is having birthday this months and having 50% discount. Do you want to utilies?", "Warning",
                                                               MessageBoxButtons.YesNo);

                        if (result1 == DialogResult.Yes)
                        {
                            myPOS.NewBillDiscount("120046SSD");
                            myPOS.NewReceiptEntry(r["strPackageCode"].ToString(),
                                                  -1, r["strDescription"].ToString(),
                                                  1, (ACMS.Convert.ToDecimal(r["mListPrice"])), "");
                        }
                        else
                        {
                            myPOS.NewReceiptEntry(r["strPackageCode"].ToString(),
                                                  -1, r["strDescription"].ToString(),
                                                  1, ACMS.Convert.ToDecimal(r["mListPrice"]), "");
                        }
                    }
                    else
                    {
                        myPOS.NewReceiptEntry(r["strPackageCode"].ToString(),
                                              -1, r["strDescription"].ToString(),
                                              1, ACMS.Convert.ToDecimal(r["mListPrice"]), "");
                    }
                }
                // END TEST

                if (myCategoryID == 1 || myCategoryID == 3 ||                // myCategoryID == 4 ||
                    myCategoryID == 6 || myCategoryID == 14 ||
                    myCategoryID == 23)
                {
                    myPOS.NewReceiptEntry(r["strPackageCode"].ToString(),
                                          -1, r["strDescription"].ToString(),
                                          1, ACMS.Convert.ToDecimal(r["mListPrice"]), "");
                }
                else if (myCategoryID == 5)
                {
                    myPOS.NewReceiptEntry(r["strPackageCode"].ToString(), -1, r["strDescription"].ToString(), 1, ACMS.Convert.ToDecimal(r["mListPrice"]), "");
                    DataTable myTblspapacakge = myPOSHelper.SearchOnePackageCode(r["strPackageCode"].ToString());

                    if (myTblspapacakge.Rows[0]["strFreePkgCode"].ToString() != string.Empty)
                    {
                        // ACMSLogic.POSEntries myEntry = new ACMSLogic.POSEntries(r);
                        myPOS.EditItemFreebieAndDiscount(myTblspapacakge.Rows[0]["strFreePkgCode"].ToString());
                    }
                }
                else if (myCategoryID == 2)
                {
                    decimal  mBasePrice      = 0M;
                    decimal  mProRateTotal   = 0M;
                    string   strTypeCard     = string.Empty;
                    string   strCode         = string.Empty;
                    string   strDesc         = string.Empty;
                    string   strCardHolder   = txtCardHolder.Text.Trim();
                    string   strCreditCardNo = txtCreditCardNo.Text.Trim();
                    string   strRefNo        = string.Empty;
                    DateTime dtFrom          = dtProrateFrom.Value;

                    mBasePrice           = ACMS.Convert.ToDecimal(r["mListPrice"]);
                    mProRateTotal        = (2 * mBasePrice);
                    strCode              = r["strPackageCode"].ToString();
                    strDesc              = r["strDescription"].ToString();
                    lblAmount.Text       = "$" + mProRateTotal.ToString();
                    myPOS.dtPackageStart = dtFrom;
                    if (dtProrateFrom.Value.Day != 1 && dtProrateFrom.Value.Day != 16)
                    {
                        MessageBox.Show(" Please select the date either 1st or 16th of the month ");
                        this.DialogResult = DialogResult.None;
                        return;
                    }

                    {
                        myPOS.NewReceiptEntry(strCode, -1, strDesc, 1, mProRateTotal, strRefNo, strCardHolder, strTypeCard, strCreditCardNo);
                    }
                }
                else if (myCategoryID == 7 || myCategoryID == 36 || myCategoryID == 37)
                {
                    myPOS.NewReceiptEntry(r["strCreditPackageCode"].ToString(),
                                          -1, r["strDescription"].ToString(),
                                          1, ACMS.Convert.ToDecimal(r["mListPrice"]), "");
                }
                else if (myCategoryID == 38)
                {
                    myPOS.NewReceiptEntry(r["strSN"].ToString(),
                                          -1, r["strDescription"].ToString(),
                                          1, ACMS.Convert.ToDecimal(r["mValue"]), "");
                }
                else if (myCategoryID == 8 || myCategoryID == 9)
                {
                    myPOS.NewReceiptEntry(r["strPackageGroupCode"].ToString(),
                                          -1, r["strDescription"].ToString(),
                                          1, ACMS.Convert.ToDecimal(r["mListPrice"]), "");
                }
                else if (myCategoryID == 11 || myCategoryID == 12)
                {
                    myPOS.NewReceiptEntry(r["strProductCode"].ToString(),
                                          -1, r["strDescription"].ToString(),
                                          1, ACMS.Convert.ToDecimal(r["mBaseUnitPrice"]), "");
                }
            }
        }
        public void Initialize()
        {
            try
            {
                using (var context = new KucsaManagementDatabaseEntities())
                {
                    context.Database.CreateIfNotExists();

                    if (context.TblMembers.Any())
                    {
                        return;
                    }

                    var course = new TblCourse[]
                    {
                        new TblCourse {
                            CourseName = "Software Engineering", CourseFaculty = "FIST"
                        },
                        new TblCourse {
                            CourseName = "Computer Science", CourseFaculty = "FIST"
                        },
                        new TblCourse {
                            CourseName = "Applied Computer Science", CourseFaculty = "FIST"
                        },
                    };

                    foreach (TblCourse c in course)
                    {
                        context.TblCourses.Add(c);
                    }
                    context.SaveChanges();

                    var language = new TblLanguage[]
                    {
                        new TblLanguage {
                            Language = "CSharp", LanguageAuthor = "Billy", LanguageTuitorial = "github.com/Docs/Csharp", LanguageWebsite = "www.microsoft.com",
                        },
                        new TblLanguage {
                            Language = "Java", LanguageAuthor = "Microsuns", LanguageTuitorial = "www.javatuitorialspoint.com", LanguageWebsite = "www.java.com",
                        },
                        new TblLanguage {
                            Language = "Javascript", LanguageAuthor = "Githithu", LanguageTuitorial = "www.w3schools.com", LanguageWebsite = "www.javascript.com",
                        },
                    };

                    foreach (TblLanguage l in language)
                    {
                        context.TblLanguages.Add(l);
                    }
                    context.SaveChanges();

                    var module = new TblModule[]
                    {
                        new TblModule {
                            Title = "CSharp Applications", ModuleLeader = "Githithu"
                        },
                        new TblModule {
                            Title = "Android Applications", ModuleLeader = "Benson"
                        },
                        new TblModule {
                            Title = "Web Development", ModuleLeader = "Gabriel"
                        },
                        new TblModule {
                            Title = "Video Editting", ModuleLeader = "Erick"
                        },
                    };

                    foreach (TblModule m in module)
                    {
                        context.TblModules.Add(m);
                    }
                    context.SaveChanges();

                    var role = new TblRole[]
                    {
                        new TblRole {
                            RoleName = "Chairman"
                        },
                        new TblRole {
                            RoleName = "Treasurer"
                        },
                        new TblRole {
                            RoleName = "Vice-Chair"
                        },
                        new TblRole {
                            RoleName = "Member"
                        },
                    };

                    foreach (TblRole r in role)
                    {
                        context.TblRoles.Add(r);
                    }
                    context.SaveChanges();

                    var member = new TblMember[]
                    {
                        new TblMember {
                            MemberName = "Githithu", MemberRegistration = "IN16/20143/13", MemberBigPicture = BigPictureNP(), CourseId = 1, ModuleId = 1, RoleId = 2,
                        },
                        new TblMember {
                            MemberName = "Okiora", MemberRegistration = "INP16/20257/13", CourseId = 1, ModuleId = 2, RoleId = 1,
                        },
                        new TblMember {
                            MemberName = "Otenyo", MemberRegistration = "IN16/20168/13", CourseId = 1, ModuleId = 3, RoleId = 3,
                        },
                        new TblMember {
                            MemberName = "Taka", MemberRegistration = "IN14/20132/13", CourseId = 3, ModuleId = 1, RoleId = 4,
                        },
                    };

                    foreach (TblMember m in member)
                    {
                        context.TblMembers.Add(m);
                    }
                    context.SaveChanges();

                    var project = new TblProject[]
                    {
                        new TblProject {
                            ProjectTitle = "KUCSA Management Software", ProjectDesc = "Desktop Application", ProjectLink = "kedevelopers.com", LanguageId = 1, MemberId = 1
                        },
                        new TblProject {
                            ProjectTitle = "ITax Returns", ProjectDesc = "Android App", ProjectLink = "kedevelopers.com", LanguageId = 2, MemberId = 2
                        },
                        new TblProject {
                            ProjectTitle = "Love Quotes", ProjectDesc = "Android App", ProjectLink = "kedevelopers.com", LanguageId = 2, MemberId = 3
                        },
                    };

                    foreach (TblProject p in project)
                    {
                        context.TblProjects.Add(p);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #25
0
        /// <summary>
        /// Include member or non member
        /// </summary>
        /// <param name="isMember"></param>
        /// <param name="branchCode"></param>
        /// <param name="name"></param>
        /// <param name="isSingaporean"></param>
        /// <param name="NRIC"></param>
        /// <param name="nSignUpID"></param>
        /// <param name="dob"></param>
        /// <param name="aUser"></param>
        ///
        /// 0705
        public string AddNewMember(bool isMember, string branchCode, string name, bool isSingaporean, string NRIC, int nSignUpID,
                                   DateTime dob, User aUser, bool isFemale, int nmediaSource)
        {
            string    membershipID = string.Empty;
            TblMember sqlMember    = new TblMember();

            sqlMember.FMember       = isMember;
            sqlMember.StrMemberName = name;
            sqlMember.FFemale       = isFemale;
            if (name.Length >= 19)
            {
                sqlMember.StrCardName = name.Substring(0, 19);
            }
            else
            {
                sqlMember.StrCardName = name;
            }
            sqlMember.StrNRICFIN     = NRIC;
            sqlMember.DtDOB          = dob;
            sqlMember.StrBranchCode  = branchCode;
            sqlMember.FSingaporean   = isSingaporean;
            sqlMember.NMediaSourceID = nmediaSource;
            TblCardRequest sqlCardRequest = new TblCardRequest();
            TblAudit       sqlAudit       = new TblAudit();

            if (!isMember)
            {
                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
                TblCompany sqlCompany = new TblCompany();

                try
                {
                    sqlCompany.MainConnectionProvider     = connProvider;
                    sqlMember.MainConnectionProvider      = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;
                    sqlAudit.MainConnectionProvider       = connProvider;
                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("AddNewNonMember");

                    sqlCompany.IncOne();
                    sqlMember.NMembershipNo   = sqlCompany.NNonMembershipNo;
                    sqlMember.NStatus         = 1;
                    sqlMember.NSignupID       = nSignUpID;
                    sqlMember.StrMembershipID = "NMC" + sqlCompany.NNonMembershipNo;
                    sqlMember.DtSignupDate    = DateTime.Now;
                    //sqlMember.NCardStatusID = (int)CardStatusType.RequestPrint;
                    sqlMember.NLoyaltyStatusID = 1;
                    sqlMember.Insert();

                    membershipID = "NMC" + sqlCompany.NNonMembershipNo;

                    connProvider.CommitTransaction();
                }
                catch (Exception)
                {
                    connProvider.RollbackTransaction("AddNewNonMember");
                    throw;
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                    {
                        connProvider.CurrentTransaction.Dispose();
                    }
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                        {
                            connProvider.DBConnection.Close();
                        }
                        connProvider.DBConnection.Dispose();
                    }
                    sqlCompany.MainConnactionIsCreatedLocal     = true;
                    sqlMember.MainConnactionIsCreatedLocal      = true;
                    sqlCardRequest.MainConnactionIsCreatedLocal = true;
                }
            }
            else
            {
                ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
                TblBranch sqlBranch = new TblBranch();

                try
                {
                    sqlBranch.MainConnectionProvider      = connProvider;
                    sqlMember.MainConnectionProvider      = connProvider;
                    sqlCardRequest.MainConnectionProvider = connProvider;
                    sqlAudit.MainConnectionProvider       = connProvider;
                    connProvider.OpenConnection();
                    connProvider.BeginTransaction("AddNewNonMember");

                    sqlBranch.StrBranchCode = branchCode;
                    //sqlBranch.StrBranchCode = "PM";
                    sqlBranch.IncOne();
                    sqlMember.NMembershipNo   = sqlBranch.NMembershipNo;
                    sqlMember.NStatus         = 1;
                    sqlMember.NSignupID       = nSignUpID;
                    sqlMember.StrMembershipID = branchCode.TrimEnd() + sqlBranch.NMembershipNo;
                    // sqlMember.StrMembershipID = "PM" + sqlBranch.NMembershipNo;
                    sqlMember.DtSignupDate      = DateTime.Now;
                    sqlMember.NCardStatusID     = (int)CardStatusType.RequestPrint;
                    sqlMember.StrCardBranchCode = "HQ";
                    sqlMember.NLoyaltyStatusID  = 1;
                    sqlMember.Insert();

                    //Request print for member --now only for fitness member
//					sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
//					sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
//					sqlCardRequest.StrBranchCode = aUser.StrBranchCode();
//					sqlCardRequest.StrMembershipID = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
//					sqlCardRequest.DtLastEditDate = DateTime.Now;
//					sqlCardRequest.Insert();

                    //Audit trail for request print
//					sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
//					sqlAudit.NEmployeeID = aUser.NEmployeeID();
//					sqlAudit.StrAuditEntry = "New member card request when create new member.";
//					sqlAudit.StrReference = branchCode.TrimEnd() +sqlBranch.NMembershipNo;
//					sqlAudit.DtDate = DateTime.Now;
//					sqlAudit.Insert();

                    membershipID = branchCode.TrimEnd() + sqlBranch.NMembershipNo;

                    connProvider.CommitTransaction();
                }
                catch (Exception)
                {
                    connProvider.RollbackTransaction("AddNewNonMember");
                    throw;
                }
                finally
                {
                    if (connProvider.CurrentTransaction != null)
                    {
                        connProvider.CurrentTransaction.Dispose();
                    }
                    if (connProvider.DBConnection != null)
                    {
                        if (connProvider.DBConnection.State == ConnectionState.Open)
                        {
                            connProvider.DBConnection.Close();
                        }
                        connProvider.DBConnection.Dispose();
                    }
                    sqlBranch.Dispose();
                    sqlMember.Dispose();
                    sqlCardRequest.Dispose();
                }
            }

            return(membershipID);
        }
Exemple #26
0
        public string ConvertMember(DataRow rowMember, User aUser)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember      sqlMember      = new TblMember();
            TblBranch      sqlBranch      = new TblBranch();
            TblAudit       sqlAudit       = new TblAudit();
            TblCardRequest sqlCardRequest = new TblCardRequest();

            try
            {
                sqlBranch.MainConnectionProvider      = connProvider;
                sqlMember.MainConnectionProvider      = connProvider;
                sqlAudit.MainConnectionProvider       = connProvider;
                sqlCardRequest.MainConnectionProvider = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("ConvertMember");

                sqlBranch.StrBranchCode = aUser.StrBranchCode();
                sqlBranch.IncOne();
                string newMembershipID = aUser.StrBranchCode().TrimEnd() + sqlBranch.NMembershipNo;
                sqlMember.StrBranchCode = aUser.StrBranchCode();
                sqlMember.ConvertMember(rowMember["strMembershipID"].ToString(), newMembershipID);
                sqlMember.ConvertMemberPurchase(rowMember["strMembershipID"].ToString(), newMembershipID);
                sqlAudit.UpdateAllWstrReferenceLogic(newMembershipID, rowMember["strMembershipID"].ToString());
                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Convert member from " + rowMember["strMembershipID"].ToString() + " to " + newMembershipID;
                sqlAudit.StrReference  = newMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                //Request print for convert non member to member
                //sqlCardRequest.NEmployeeID = aUser.NEmployeeID();
                //sqlCardRequest.NStatusID = (int)CardStatusType.RequestPrint;
                //sqlCardRequest.StrBranchCode = aUser.StrBranchCode();
                //sqlCardRequest.StrMembershipID = newMembershipID;
                //sqlCardRequest.DtLastEditDate = DateTime.Now;
                //sqlCardRequest.Insert();

                ////Audit trail for request print
                //sqlAudit.NAuditTypeID = ACMSLogic.AuditTypeID.MemberCard;
                //sqlAudit.NEmployeeID = aUser.NEmployeeID();
                //sqlAudit.StrAuditEntry = "New member card request when create convert member.";
                //sqlAudit.StrReference = newMembershipID;
                //sqlAudit.DtDate = DateTime.Now;
                //sqlAudit.Insert();

                connProvider.CommitTransaction();
                return(newMembershipID);
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("ConvertMember");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlBranch.Dispose();
                sqlMember.Dispose();
                sqlAudit.Dispose();
                sqlCardRequest.Dispose();
            }
        }
Exemple #27
0
 private void Init()
 {
     myMember    = new TblMember();
     myDataTable = myMember.SelectAllForLookupEdit();
 }
Exemple #28
0
        /// <summary>
        /// Use Member Credit Package means use the credit to buy the package and then store in the tblMemberPackage
        /// be aware some package is not allow to purchase using credit package. Must check tblCreditPackageRestriction
        /// </summary>
        /// <returns></returns>
        public string[,] UseMemberCreditPackage(string[,] strPackageCode,
                                                int nCreditPackageID, string strSignID, string strSigKey, string strPdfExportPath, string remark)
        {
            //ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            DataRow[] rows, row1s = new DataRow[strPackageCode.Length / 2];
            string[,] strUsage = new string[strPackageCode.Length / 2, 3];
            //DataColumn[] dc = new DataColumn["Usage",System.Type.GetType("System.Int")];

            try
            {
                TblMemberCreditPackage memberCreditPackage = new TblMemberCreditPackage();

                //connProvider.OpenConnection();
                //connProvider.BeginTransaction("UseMemberCreditPackage");

                //memberCreditPackage.MainConnectionProvider = connProvider;
                memberCreditPackage.NCreditPackageID = nCreditPackageID;
                DataTable table = memberCreditPackage.SelectOne();

                if (table == null || table.Rows.Count == 0)
                {
                    throw new Exception("This member credit package been deleted by others");
                }

                if (ACMS.Convert.ToInt32(table.Rows[0]["nStatusID"]) > 0)
                {
                    throw new Exception("This member credit package has been deleted/expired/suspended.");
                }

                string strCreditPackageCode             = memberCreditPackage.StrCreditPackageCode.Value;
                string strMembershipID                  = memberCreditPackage.StrMembershipID.Value;
                TblCreditPackageRestriction restriction = new TblCreditPackageRestriction();
                restriction.StrCreditPackageCode = strCreditPackageCode;
                TblReceipt creditReceipt = new TblReceipt();
                if (!memberCreditPackage.StrReceiptNo.IsNull)
                {
                    creditReceipt.StrReceiptNo = memberCreditPackage.StrReceiptNo.Value;
                    creditReceipt.SelectOne();
                }

                DataTable  restricttable = restriction.SelectAllWstrCreditPackageCodeLogic();
                DataColumn colQuantity   = new DataColumn("colQuantity", System.Type.GetType("System.Int32"));
                restricttable.Columns.Add(colQuantity);

                bool isAllowDiscount = false;

                if (restricttable.Rows.Count == 0)
                {
                    throw new Exception("No allow to use credit package for this package.");
                }
                else
                {
                    for (int j = 0; j < strPackageCode.Length / 2; j++)
                    {
                        rows = restricttable.Select("strPackageCode = '" + strPackageCode[j, 0] + "'", "strCreditPackageCode");
                        rows[0]["colQuantity"] = strPackageCode[j, 1];
                        row1s[j] = rows[0];
                    }
                    if (row1s.Length == 0)
                    {
                        throw new Exception("No allow to use credit package for this package.");
                    }
                    // check later as got two package now
                    //else
                    //{
                    //    isAllowDiscount = ACMS.Convert.ToBoolean(row1s[0]["fAllowDiscount"]);
                    //}
                }

                // Must Check balance is enough to buy a Package or not
                TblCreditPackage creditPackage = new TblCreditPackage();
                creditPackage.StrCreditPackageCode = memberCreditPackage.StrCreditPackageCode.Value;
                creditPackage.SelectOne();

                decimal creditPackageValue         = ACMS.Convert.ToDecimal(creditPackage.MCreditAmount);
                decimal mmbCreditPackageFreeCredit = ACMS.Convert.ToDecimal(creditPackage.MFreeCredit);
                decimal mmbCreditPackageTopupAmt   = ACMS.Convert.ToDecimal(memberCreditPackage.MTopupAmount);

                decimal totalCreditUsage = GetCreditUsageFromMemberPackage(nCreditPackageID);

                decimal balance = (creditPackageValue + mmbCreditPackageTopupAmt + mmbCreditPackageFreeCredit) - totalCreditUsage;

                if (creditReceipt.MOutstandingAmount > 0 && !memberCreditPackage.StrReceiptNo.IsNull)
                {
                    DataTable creditUsageMemberPackage = null;
                    RefreshForPackageUsage(strMembershipID, ACMS.Convert.ToInt32(creditPackage.NCategoryID));
                    creditUsageMemberPackage = myDataTable;

                    double m70PercPaidAmount = 0;
                    if (creditUsageMemberPackage.Rows.Count > 0)
                    {
                        m70PercPaidAmount = ACMS.Convert.ToDouble(creditUsageMemberPackage.Select("nCreditPackageID=" + nCreditPackageID)[0]["PaidAmt"]) * 0.7;
                    }

                    if (totalCreditUsage > ACMS.Convert.ToDecimal(m70PercPaidAmount))
                    {
                        throw new Exception(string.Format("Total usage is more than 70% of paid amount. \n Please clear the outstanding."));
                    }
                }

                if (balance < 0)
                {
                    throw new Exception(string.Format("Balance for Member Credit Package : {0} is not enough.\n Please topup your credit.", nCreditPackageID.ToString()));
                }

                // Need to know here whether it is 1st use
                TblMemberPackage mp = new TblMemberPackage();
                //mp.MainConnectionProvider = connProvider;
                mp.NCreditPackageID = nCreditPackageID;
                DataTable temptable = mp.SelectAllWnCreditPackageIDLogic();

                bool is1stUseCreditPck = false;
                if (Convert.ToInt32(temptable.Compute("COUNT(nStatusID)", "nStatusID=0 or nStatusID=1")) == 0)
                {
                    //means news insert
                    is1stUseCreditPck = true;
                }
                int i = 0;
                foreach (DataRow drPackage in row1s)
                {
                    for (int x = 0; x < ACMS.Convert.ToInt32(drPackage[3]); x++) // quantity
                    {
                        MemberPackage memberPackage      = new MemberPackage();
                        DataTable     memberPackageTable = memberPackage.New(false, strMembershipID);
                        DataRow       memberPackageRow   = memberPackageTable.Rows[0];
                        memberPackageRow["nCreditPackageID"] = nCreditPackageID;
                        memberPackageRow["strMembershipID"]  = strMembershipID;
                        memberPackageRow["dtPurchaseDate"]   = DateTime.Now;
                        memberPackageRow["strRemarks"]       = remark;
                        memberPackageRow["strSignatureID"]   = strSignID;
                        memberPackageRow["strSigKey"]        = strSigKey;
                        memberPackageRow["strSigPdfPath"]    = strPdfExportPath;
                        memberPackageRow["strUtilData"]      = strSigKey;
                        memberPackageRow["nStatusID"]        = 0;

                        memberPackageRow["strPackageCode"] = drPackage["strPackageCode"]; //strPackageCode;
                        TblPackage package = new TblPackage();
                        package.StrPackageCode = drPackage["strPackageCode"].ToString();  // strPackageCode;
                        package.SelectOne();
                        decimal creditUsage      = 0;
                        decimal packageListPrice = ACMS.Convert.ToDecimal(package.MListPrice);

                        TblMember sqlMember = new TblMember();
                        //Check if redeemed spa single treatment from holistic in birthday month, give 50% discount
                        if ((creditPackage.NCategoryID == 36 || creditPackage.NCategoryID == 37) && (package.NCategoryID == 4 || (package.NCategoryID == 6 && package.NMaxSession == 1)) && sqlMember.MembershipThisMonthBirtdayForUtilised(strMembershipID, nCreditPackageID))
                        {
                            DialogResult result1 = MessageBox.Show("Member is having birthday this months and having 50% discount. Do you want to utilies?", "Warning",
                                                                   MessageBoxButtons.YesNo);

                            if (result1 == DialogResult.Yes)
                            {
                                double discountPercent = 50;
                                memberPackageRow["strPromotionCode"] = "120046SSD";
                                // calcualte usage * quantity
                                creditUsage = packageListPrice - (packageListPrice * (decimal)discountPercent / 100);
                            }
                            else
                            {
                                if (ACMS.Convert.ToBoolean(drPackage["fAllowDiscount"]))
                                {
                                    double discountPercent = creditPackage.DCreditDiscount.Value;
                                    // calcualte usage * quantity
                                    creditUsage = packageListPrice - (packageListPrice * (decimal)discountPercent / 100);
                                }
                                else
                                {
                                    creditUsage = packageListPrice;
                                }
                            }
                        }
                        else if (ACMS.Convert.ToBoolean(drPackage["fAllowDiscount"]))
                        {
                            double discountPercent = creditPackage.DCreditDiscount.Value;
                            // calcualte usage * quantity
                            creditUsage = packageListPrice - (packageListPrice * (decimal)discountPercent / 100);
                        }
                        else
                        {
                            creditUsage = packageListPrice;
                        }

                        decimal previousBal = balance;
                        balance = decimal.Parse(previousBal.ToString("N2")) - decimal.Parse(creditUsage.ToString("N2"));
                        if (balance < 0)
                        {
                            throw new Exception(string.Format("Balance for Member Credit Package : {0} is not enough. \n Please topup your credit.", nCreditPackageID.ToString()));
                        }

                        memberPackageRow["mCreditPackageUsagePrice"] = creditUsage;
                        memberPackageRow["strRemarks"] = memberPackageRow["strRemarks"] + " " + x;

                        //Initially designed for immediate kick start
                        if (memberPackageRow["dtStartDate"].ToString() == "")
                        {
                            int      iduration = package.NPackageDuration.Value;
                            DateTime dtNow     = DateTime.Now.Date;
                            memberPackageRow["dtStartDate"] = dtNow;
                            if (package.StrDurationUnit.ToString().Trim() == "DAY")
                            {
                                memberPackageRow["dtExpiryDate"] = dtNow.AddDays(iduration - 1).AddDays(0);
                            }
                            else if (package.StrDurationUnit.ToString().Trim() == "WEEK")
                            {
                                iduration = iduration * 7;
                                memberPackageRow["dtExpiryDate"] = dtNow.AddDays(iduration - 1).AddDays(0);
                            }
                            else
                            {
                                memberPackageRow["dtExpiryDate"] = dtNow.AddMonths(iduration).AddDays(-1);
                            }
                        }

                        mp.SaveData(memberPackageTable);
                        strUsage[i, 0] = package.StrDescription.ToString();
                        strUsage[i, 1] = creditUsage.ToString();
                    }

                    strUsage[i, 2] = drPackage[3].ToString();
                    i++;
                }

                if (is1stUseCreditPck)
                {
                    if (memberCreditPackage.DtStartDate.ToString() == "Null")
                    {
                        memberCreditPackage.NCreditPackageID = nCreditPackageID;
                        memberCreditPackage.DtStartDate      = DateTime.Now.Date;
                        memberCreditPackage.DtExpiryDate     = DateTime.Now.Date.AddMonths(ACMS.Convert.ToInt32(creditPackage.NValidMonths)).AddDays(-1);
                        memberCreditPackage.Update();
                    }
                }

                //connProvider.CommitTransaction();
            }
            catch (Exception)
            {
                //connProvider.RollbackTransaction("UseMemberCreditPackage");
                throw;
            }
            finally
            {
                //if (connProvider.CurrentTransaction != null)
                //    connProvider.CurrentTransaction.Dispose();
                //if (connProvider.DBConnection != null)
                //{
                //    if (connProvider.DBConnection.State == ConnectionState.Open)
                //        connProvider.DBConnection.Close();
                //}
            }
            return(strUsage);
        }
Exemple #29
0
        public bool UpdateMember(string strMembershipID,
                                 object dateDob,
                                 bool fAirCrew,
                                 bool fBoundCheck,
                                 bool fEmail,
                                 bool fGiroFailed,
                                 bool fPostalMail,
                                 bool fSingaporean,
                                 bool fSMS,
                                 int nLoyaltyStatusID,
                                 string strAdd1,
                                 string strAdd2,
                                 string strAltEmail,
                                 string strCardName,
                                 string strCompany,
                                 string strCreditCardNo,
                                 string strEmail,
                                 string strEmergencyContactNo,
                                 string strEmergencyContactPerson,
                                 string strHomeNo,
                                 string strMemberName,
                                 string strMobileNo,
                                 string strNIRCFIN,
                                 string strOccupation,
                                 string strOfficeNo,
                                 string strPagerNo,
                                 string strPostalCode,
                                 string strRemark,
                                 int nMediaSourceID,
                                 string strMediaSource,
                                 string strBeforePhoto,
                                 string strAfterPhoto,
                                 byte[] imgPhoto,
                                 User aUser,
                                 bool fFemale,
                                 bool fPhoneCall,
                                 string strSecurityQuestion,
                                 string strSecurityAnswer,
                                 string strMobileAppPwd)
        {
            ACMSDAL.ConnectionProvider connProvider = new ConnectionProvider();
            TblMember sqlMember = new TblMember();
            TblAudit  sqlAudit  = new TblAudit();

            bool isSuccess = false;

            try
            {
                sqlMember.MainConnectionProvider = connProvider;
                sqlAudit.MainConnectionProvider  = connProvider;
                connProvider.OpenConnection();
                connProvider.BeginTransaction("UpdateMemberRecord");

                sqlMember.StrMembershipID = strMembershipID;
                sqlMember.FFemale         = fFemale;
                sqlMember.FAirCrew        = fAirCrew;
                sqlMember.FBounceCheck    = fBoundCheck;
                sqlMember.FEmail          = fEmail;
                sqlMember.FGIROFailed     = fGiroFailed;
                sqlMember.FPostalMail     = fPostalMail;
                sqlMember.FSingaporean    = fSingaporean;
                sqlMember.FSMS            = fSMS;
                sqlMember.FPhoneCall      = fPhoneCall;

                if (nLoyaltyStatusID != 0)
                {
                    sqlMember.NLoyaltyStatusID = nLoyaltyStatusID;
                }

                sqlMember.StrAddress1               = strAdd1;
                sqlMember.StrAddress2               = strAdd2;
                sqlMember.StrAltEmail               = strAltEmail;
                sqlMember.StrCardName               = strCardName;
                sqlMember.StrCompany                = strCompany;
                sqlMember.StrCreditCardNo           = strCreditCardNo;
                sqlMember.StrEmail                  = strEmail;
                sqlMember.StrEmergencyContactNumber = strEmergencyContactNo;
                sqlMember.StrEmergencyContactPerson = strEmergencyContactPerson;
                sqlMember.StrHomeNo                 = strHomeNo;
                sqlMember.StrMemberName             = strMemberName;
                sqlMember.StrMobileNo               = strMobileNo;
                sqlMember.StrNRICFIN                = strNIRCFIN;
                sqlMember.StrOccupation             = strOccupation;
                sqlMember.StrOfficeNo               = strOfficeNo;
                sqlMember.StrPagerNo                = strPagerNo;
                sqlMember.StrPostalCode             = strPostalCode;
                sqlMember.StrRemarks                = strRemark;
                sqlMember.NMediaSourceID            = nMediaSourceID;
                sqlMember.StrMediaSource            = strMediaSource;
                sqlMember.NEmployeeID               = aUser.NEmployeeID();
                sqlMember.StrSecurityQuestion       = strSecurityQuestion;
                sqlMember.StrSecurityAnswer         = strSecurityAnswer;
                sqlMember.StrPassword               = strMobileAppPwd;

                sqlMember.Update2(dateDob, strBeforePhoto, strAfterPhoto, imgPhoto);

                sqlAudit.NAuditTypeID  = ACMSLogic.AuditTypeID.MemberRecord;
                sqlAudit.NEmployeeID   = aUser.NEmployeeID();
                sqlAudit.StrAuditEntry = "Update member " + strMembershipID;
                sqlAudit.StrReference  = strMembershipID;
                sqlAudit.DtDate        = DateTime.Now;
                sqlAudit.Insert();

                connProvider.CommitTransaction();
                isSuccess = true;
            }
            catch (Exception)
            {
                connProvider.RollbackTransaction("UpdateMemberRecord");
                throw;
            }
            finally
            {
                if (connProvider.CurrentTransaction != null)
                {
                    connProvider.CurrentTransaction.Dispose();
                }
                if (connProvider.DBConnection != null)
                {
                    if (connProvider.DBConnection.State == ConnectionState.Open)
                    {
                        connProvider.DBConnection.Close();
                    }
                    connProvider.DBConnection.Dispose();
                }
                sqlMember.Dispose();
                sqlAudit.Dispose();
            }
            return(isSuccess);
        }