// copy private void btnCopy_Click(object sender, EventArgs e) { if (cmbType.SelectedIndex < 0) { m_nCopyType = -1; m_lstPoint.Clear(); return; } int nCount = lstvwPoint.Items.Count; m_lstPoint.Clear(); for (int i = 0; i < nCount; i++) { clsPoint point = new clsPoint(); point.m_nIndex = Convert.ToInt32(lstvwPoint.Items[i].Text); point.m_strName = lstvwPoint.Items[i].SubItems[1].Text; point.m_strSerialNumber = lstvwPoint.Items[i].SubItems[2].Text; // 2016.08.01 by kdi point.m_strPixelFormat = lstvwPoint.Items[i].SubItems[3].Text; m_lstPoint.Add(point); } m_nCopyType = cmbType.SelectedIndex; btnPaste.Enabled = true; }
public static List <int> UpdateUserSpinStatus(int reward) { //define empty int list List <int> couponList = new List <int>(); //if reward count is greater than 0 then loop number of reward count and add coupon code (if 2 rewards then 2 coupons) if (reward > 0) { //first add number of points into point table/in here number of rewards are multiplied by 5 (1 reward coupon = 5 points) mgtPoint.Add(userId, reward * 5); //retive current points object fro the user clsPoint points = mgtPoint.GetPoints(userId); for (int i = 0; i < reward; i++) { //create coupon object clsCoupon coupon = new clsCoupon(); coupon.PointId = points.Id; coupon.Code = GenerateRandomNo(); //save coupon mgtCoupon.Add(coupon); //send coupon mail mgtMails.SendCouponCode(userId, coupon.Code); //add each coupon code created into int list couponList.Add(coupon.Code); } } //update spinned status for the user mgtUSer.UpdateUserSpinStatus(userId); //return coupon list return(couponList); }
private void GenerateCoupon(int userId) { clsPoint points = mgtPoint.GetPoints(userId); if (points.Points >= 5) { clsCoupon coupon = new clsCoupon(); coupon.PointId = points.Id; coupon.Code = GenerateRandomNo(); mgtCoupon.Add(coupon); mgtMails.SendCouponCode(userId, coupon.Code); } }
/// <summary> /// My neighbor function /// </summary> /// <param name="p"></param> /// <returns></returns> public override clsPoint Neighbor(clsPoint p) { var retP = p.Copy(); var n = p.GetFunc().NumberOfVariable(); int i = 0; for (; i < n - 2; i++) { retP[i] = _rng.Next(-this.Range, this.Range); //discrete value } //all 0 for (; i < n; i++) { retP[i] = 0; } return(retP); }
public void BindCoupons() { clsUser user = (clsUser)Session["User"]; clsPoint points = mgtPoint.GetPoints(user.UserID); lstCoupon.DataSource = mgtCoupon.GetCouponsDataSet(points.Id).Tables[0]; lstCoupon.DataBind(); lblTotal.Text = points.TotalPoints.ToString(); lblRedeemed.Text = points.Redeemed.ToString(); lblPoints.Text = points.Points.ToString(); int progress = 100; if (points.Points < 5) { progress = (points.Points * 100) / 5; } divProgree.Attributes.Add("class", "c100 p" + progress + " big"); lblProgress.Text = progress + "%"; }
public static clsPoint GetPoints(int userId) { try { SqlConnection con = new SqlConnection(App.GetDBCon()); SqlDataReader rd; clsPoint point = new clsPoint(); using (con) { SqlCommand cmd = new SqlCommand("sp_Get_Points", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("userId", userId); con.Open(); rd = cmd.ExecuteReader(); if (rd.Read()) { point = new clsPoint(); point.TotalPoints = Convert.ToInt32(rd["TotalPoints"].ToString()); point.Points = Convert.ToInt32(rd["Points"].ToString()); point.Redeemed = Convert.ToInt32(rd["Redeemed"].ToString()); point.UserId = Convert.ToInt32(rd["UserId"].ToString()); point.Id = Convert.ToInt32(rd["Id"].ToString()); } rd.Close(); } con.Close(); return(point); } catch (Exception) { throw; } }