예제 #1
0
 // dot button
 private void button22_Click(object sender, EventArgs e)
 {
     if (!ValidatorClass.ValidateOperator(textBox1, "."))
     {
         textBox1.Text = textBox1.Text + ".";
     }
 }
        public object SendYzmSms(string mobile)
        {
            if (!ValidatorClass.Validator(mobile, CheckType.Mobile, null, false))
            {
                return(new { Rcode = -1, Rmsg = "参数错误" });
            }
            Random            rand   = new Random();
            string            errmsg = null;
            base_identifycode info   = new base_identifycode
            {
                code     = rand.Next(100000, 999999).ToString(),
                sendtime = DateTime.Now,
                endtime  = DateTime.Now.AddMinutes(3),
                phone    = mobile
            };
            bool success = BaseBLL.PutIdentifyCode(info, out errmsg);

            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "写入验证码出错" + errmsg }
            }
            ;
            if (!SmsServiceBLL.SmsSingleSendByYunpian(mobile, info.code, null, null, true, out errmsg))
            {
                return(new { Rcode = -1, Rmsg = "发送短信出错:" + errmsg });
            }
            return(new { Rcode = 1, Rmsg = "短信已下发,请注意查收" });
        }
예제 #3
0
 // +/- operator button
 private void button23_Click(object sender, EventArgs e)
 {
     try
     {
         ValidatorClass.ValidateEntryReturn(textBox1.Text);
         textBox1.Text = UitlityClass.AppendPlusMinusOperator(textBox1.Text);
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid Operation");
     }
 }
예제 #4
0
 // subtraction button
 private void button9_Click(object sender, EventArgs e)
 {
     try
     {
         TextBoxNumber = ValidatorClass.ValidateEntryReturn(textBox1.Text);
         UitlityClass.ClearTextBox(textBox1);
         label3.Text = UitlityClass.AddTextToString(TextBoxNumber, " -");
         Operation   = OperatorCode.SUBTRATION;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Invalid Operation");
     }
 }
예제 #5
0
 // Tangent button
 private void button10_Click(object sender, EventArgs e)
 {
     try
     {
         TextBoxNumber = ValidatorClass.ValidateEntryReturn(textBox1.Text);
         UitlityClass.ClearTextBox(textBox1);
         label3.Text = UitlityClass.AddTextToString("Tan() ", TextBoxNumber);
         Operation   = OperatorCode.TANGENT;
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid Operation");
     }
 }
예제 #6
0
 //power button
 private void button20_Click(object sender, EventArgs e)
 {
     try
     {
         TextBoxNumber = ValidatorClass.ValidateEntryReturn(textBox1.Text);
         UitlityClass.ClearTextBox(textBox1);
         label3.Text = UitlityClass.AddTextToString(TextBoxNumber, " ^");
         Operation   = OperatorCode.POWER;
     }
     catch (Exception)
     {
         Console.WriteLine("Invalid Opeartion");
     }
 }
예제 #7
0
        /// <summary>
        /// Deletes product from the cart.
        /// </summary>
        /// <param name="product">Product to delete.</param>
        public void DeleteFromCart(int id)
        {
            try
            {
                ValidatorClass.CheckProductById(id);
            }
            catch (KeyNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }

            Storage.cart.Remove(id);
        }
예제 #8
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <param name="user"></param>
 /// <param name="errmsg"></param>
 /// <returns></returns>
 public int UserReg(base_user_extend user, out string errmsg)
 {
     if (user.usertype == null)
     {
         user.usertype = 1;
     }
     if (user.sourcetype == null)
     {
         user.sourcetype = 3;
     }
     if (string.IsNullOrEmpty(user.passwd))
     {
         user.passwd = Models.GlobalParameters.DefaultUserPasswd;
     }
     if (user.createdtime == null)
     {
         user.createdtime = DateTime.Now;
     }
     if (user.customerid == null)
     {
         user.customerid = 0;
     }
     user.status = 1;
     if (string.IsNullOrEmpty(user.phone) && string.IsNullOrEmpty(user.email))
     {
         errmsg = "手机号码和邮箱至少填写一个";
         return(0);
     }
     if (!ValidatorClass.Validator(user.phone, CheckType.Mobile, null, true))
     {
         errmsg = "手机号码错误";
         return(0);
     }
     if (!ValidatorClass.Validator(user.email, CheckType.Email, null, true))
     {
         errmsg = "邮箱错误";
         return(0);
     }
     if (!ValidatorClass.Validator(user.username, CheckType.Loginid, null, true))
     {
         errmsg = "用户名错误";
         return(0);
     }
     return(DAL.UserAccountDAL.UserReg(user, out errmsg));
 }
        public object SendYzmEmail(string email)
        {
            if (!ValidatorClass.Validator(email, CheckType.Email, null, false))
            {
                return(new { Rcode = -1, Rmsg = "参数错误" });
            }
            Random            rand   = new Random();
            string            errmsg = null;
            base_identifycode info   = new base_identifycode
            {
                code     = rand.Next(100000, 999999).ToString(),
                sendtime = DateTime.Now,
                endtime  = DateTime.Now.AddMinutes(5),
                email    = email
            };
            bool success = BaseBLL.PutIdentifyCode(info, out errmsg);

            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "写入验证码出错" + errmsg }
            }
            ;
            string subject = Models.GlobalParameters.SmtpSignTitle + "验证邮件";
            string content = string.Format("您的验证码为 {0} ,请勿轻易告诉他人!", info.code);

            NetClass.SmtpServer = Models.GlobalParameters.SmtpServer;
            NetClass.Account    = Models.GlobalParameters.SmtpUser;
            NetClass.Passwd     = Models.GlobalParameters.SmtpPass;
            NetClass.MailFrom   = Models.GlobalParameters.SmtpMail;
            if (!NetClass.SendMail(email, subject, content, Models.GlobalParameters.SmtpMail, ref errmsg))
            {
                return(new { Rcode = -1, Rmsg = "发送邮件出错:" + errmsg });
            }
            return(new { Rcode = 1, Rmsg = "邮件已发送,请注意查收" });
        }
    }
        public void CheckProduct_Test()
        {
            SolidProduct _pr = new SolidProduct("The Twisted Ones", "Book", 9.99m, 150);

            ValidatorClass.ProductValidator(_pr);
        }
 public void PriceValidator_FailTest()
 {
     ValidatorClass.PriceValidator(-2.99m);
 }
 public void PriceValidator_Test()
 {
     ValidatorClass.PriceValidator(213.233m);
 }
        public void CheckById_Test(int id)
        {
            ValidatorClass.CheckProductById(id);

            Assert.IsNotNull(Storage.products[id].Name);
        }
 public void CheckById_FailTest()
 {
     ValidatorClass.CheckProductById(67);
 }
 public void CheckId_Test()
 {
     ValidatorClass.CheckIdInStorage(5);
 }
 public void CheckId_FailTest()
 {
     ValidatorClass.CheckIdInStorage(1);
 }
 public void StringValidator_Test(string str)
 {
     ValidatorClass.StringValidator(str);
 }
        public void CheckProduct_FailTest()
        {
            LiquidProduct _pr = new LiquidProduct("0", "Smth", 10.99m, 1);

            ValidatorClass.ProductValidator(_pr);
        }
 public void CheckProduct_NullTest()
 {
     ValidatorClass.ProductValidator(null);
 }