Exemplo n.º 1
0
        public Int32 Save(PromoDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSavePromo(@PromoID, @PromoCode, @PromoName, @StartDate, @EndDate, @PromoTypeID, @Status, @CreatedOn, @LastModified);";

                cmd.Parameters.AddWithValue("PromoID", Details.PromoID);
                cmd.Parameters.AddWithValue("PromoCode", Details.PromoCode);
                cmd.Parameters.AddWithValue("PromoName", Details.PromoName);
                cmd.Parameters.AddWithValue("StartDate", Details.StartDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("EndDate", Details.EndDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("PromoTypeID", Details.PromoTypeID);
                cmd.Parameters.AddWithValue("Status", Details.Status);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                cmd.CommandText = SQL;
                return(base.ExecuteNonQuery(cmd));
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Exemplo n.º 2
0
		public void Update(PromoDetails Details)
		{
			try 
			{
                Save(Details);
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 3
0
 public void Update(PromoDetails Details)
 {
     try
     {
         Save(Details);
     }
     catch (Exception ex)
     {
         throw base.ThrowException(ex);
     }
 }
Exemplo n.º 4
0
        public System.Data.DataTable ListAstDataTable(PromoDetails SearchKey, string SortField = "PromoID", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "SELECT " +
                             "PromoID, " +
                             "PromoCode, " +
                             "PromoName, " +
                             "StartDate, " +
                             "EndDate, " +
                             "Status, " +
                             "a.PromoTypeID, " +
                             "PromoTypeCode, " +
                             "PromoTypeName " +
                             "FROM tblPromo a INNER JOIN " +
                             "tblPromoType b ON a.PromoTypeID = b.PromoTypeID " +
                             "WHERE 1=1 ";

                if (!string.IsNullOrEmpty(SearchKey.PromoCode))
                {
                    SQL += "AND PromoCode LIKE @PromoCode ";
                    cmd.Parameters.AddWithValue("@PromoCode", SearchKey.PromoCode);
                }
                if (!string.IsNullOrEmpty(SearchKey.PromoName))
                {
                    SQL += "AND PromoCode LIKE @PromoName ";
                    cmd.Parameters.AddWithValue("@PromoName", SearchKey.PromoName);
                }
                if (!string.IsNullOrEmpty(SearchKey.PromoTypeCode))
                {
                    SQL += "AND PromoCode LIKE @PromoTypeCode ";
                    cmd.Parameters.AddWithValue("@PromoTypeCode", SearchKey.PromoTypeCode);
                }

                SQL += "ORDER BY " + SortField + " ";
                SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC ";
                SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " ";

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                return(dt);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Exemplo n.º 5
0
		public Int64 Insert(PromoDetails Details)
		{
			try 
			{
                Save(Details);

                return Int64.Parse(base.getLAST_INSERT_ID(this));
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 6
0
        public Int64 Insert(PromoDetails Details)
        {
            try
            {
                Save(Details);

                return(Int64.Parse(base.getLAST_INSERT_ID(this)));
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Exemplo n.º 7
0
        public PromoDetails Details(Int64 PromoID)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "SELECT " +
                             "PromoID, " +
                             "PromoCode, " +
                             "PromoName, " +
                             "StartDate, " +
                             "EndDate, " +
                             "Status, " +
                             "a.PromoTypeID, " +
                             "PromoTypeCode, " +
                             "PromoTypeName " +
                             "FROM tblPromo a " +
                             "INNER JOIN tblPromoType b ON a.PromoTypeID = b.PromoTypeID " +
                             "WHERE a.PromoID = @PromoID;";

                cmd.Parameters.AddWithValue("@PromoID", PromoID);

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                PromoDetails Details = new PromoDetails();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.PromoID       = Int64.Parse(dr["PromoID"].ToString());
                    Details.PromoCode     = "" + dr["PromoCode"].ToString();
                    Details.PromoName     = "" + dr["PromoName"].ToString();
                    Details.StartDate     = DateTime.Parse(dr["StartDate"].ToString());
                    Details.EndDate       = DateTime.Parse(dr["EndDate"].ToString());
                    Details.PromoTypeID   = Int32.Parse(dr["PromoTypeID"].ToString());
                    Details.PromoTypeCode = "" + dr["PromoTypeCode"].ToString();
                    Details.PromoTypeName = "" + dr["PromoTypeName"].ToString();
                }

                return(Details);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Exemplo n.º 8
0
		private void LoadList()
		{	
			Promo clsPromo = new Promo();
			DataClass clsDataClass = new DataClass();

			string SortField = "PromoName";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}
			
			SortOption sortoption = SortOption.Ascending;
			if (Request.QueryString["sortoption"]!=null)
			{	sortoption = (SortOption) Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);	}

            PromoDetails clsSearchKey = new PromoDetails();

			if (Request.QueryString["Search"]!=null)
			{
                clsSearchKey.PromoCode = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID);
			}

            PageData.DataSource = clsPromo.ListAstDataTable(clsSearchKey, SortField, sortoption).DefaultView;

			clsPromo.CommitAndDispose();

			int iPageSize = Convert.ToInt16(Session["PageSize"]) ;
			
			PageData.AllowPaging = true;
			PageData.PageSize = iPageSize;
			try
			{
				PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;				
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}
			catch
			{
				PageData.CurrentPageIndex = 1;
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}			
			
			cboCurrentPage.Items.Clear();
			for (int i=0; i < PageData.PageCount;i++)
			{
				int iValue = i + 1;
				cboCurrentPage.Items.Add(new ListItem(iValue.ToString(),iValue.ToString()));
				if (PageData.CurrentPageIndex == i)
				{	cboCurrentPage.Items[i].Selected = true;}
				else
				{	cboCurrentPage.Items[i].Selected = false;}
			}
			lblDataCount.Text = " of " + " " + PageData.PageCount;
		}
Exemplo n.º 9
0
		private Int64 SaveRecord()
		{
            long lngRetValue = 0;
            string stScript = string.Empty;

            DateTime dteStartDateTime = DateTime.MinValue;
            try { dteStartDateTime = Convert.ToDateTime(txtStartDate.Text + " " + txtStartTime.Text); }
            catch {
                stScript += "<Script>";
                stScript += "window.alert('Please enter a valid start date time of promo.')";
                stScript += "</Script>";
                Response.Write(stScript);	
                return lngRetValue ; 
            }
            DateTime dteEndDateTime = DateTime.MinValue;
            try { dteEndDateTime = Convert.ToDateTime(txtEndDate.Text + " " + txtEndTime.Text); }
            catch
            {
                stScript += "<Script>";
                stScript += "window.alert('Please enter a valid end date time of promo.')";
                stScript += "</Script>";
                Response.Write(stScript);
                return lngRetValue;
            }

			Promo clsPromo = new Promo();
			PromoDetails clsDetails = new PromoDetails();

			clsDetails.PromoCode = txtPromoCode.Text;
			clsDetails.PromoName = txtPromoName.Text;
			clsDetails.StartDate = dteStartDateTime;
			clsDetails.EndDate = dteEndDateTime;
			clsDetails.PromoTypeID = Convert.ToInt32(cboPromoType.SelectedItem.Value);

			lngRetValue = clsPromo.Insert(clsDetails);
			
			clsPromo.CommitAndDispose();

			return lngRetValue;
		}
Exemplo n.º 10
0
        public Int32 Save(PromoDetails Details)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "CALL procSavePromo(@PromoID, @PromoCode, @PromoName, @StartDate, @EndDate, @PromoTypeID, @Status, @CreatedOn, @LastModified);";

                cmd.Parameters.AddWithValue("PromoID", Details.PromoID);
                cmd.Parameters.AddWithValue("PromoCode", Details.PromoCode);
                cmd.Parameters.AddWithValue("PromoName", Details.PromoName);
                cmd.Parameters.AddWithValue("StartDate", Details.StartDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("EndDate", Details.EndDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("PromoTypeID", Details.PromoTypeID);
                cmd.Parameters.AddWithValue("Status", Details.Status);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                cmd.CommandText = SQL;
                return base.ExecuteNonQuery(cmd);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Exemplo n.º 11
0
		public System.Data.DataTable ListAstDataTable(PromoDetails SearchKey, string SortField = "PromoID", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0)
		{
			try
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

                string SQL = "SELECT " +
                                    "PromoID, " +
                                    "PromoCode, " +
                                    "PromoName, " +
                                    "StartDate, " +
                                    "EndDate, " +
                                    "Status, " +
                                    "a.PromoTypeID, " +
                                    "PromoTypeCode, " +
                                    "PromoTypeName " +
                                "FROM tblPromo a INNER JOIN " +
                                "tblPromoType b ON a.PromoTypeID = b.PromoTypeID " +
                                "WHERE 1=1 ";

                if (!string.IsNullOrEmpty(SearchKey.PromoCode))
                {
                    SQL += "AND PromoCode LIKE @PromoCode ";
                    cmd.Parameters.AddWithValue("@PromoCode", SearchKey.PromoCode);
                }
                if (!string.IsNullOrEmpty(SearchKey.PromoName))
                {
                    SQL += "AND PromoCode LIKE @PromoName ";
                    cmd.Parameters.AddWithValue("@PromoName", SearchKey.PromoName);
                }
                if (!string.IsNullOrEmpty(SearchKey.PromoTypeCode))
                {
                    SQL += "AND PromoCode LIKE @PromoTypeCode ";
                    cmd.Parameters.AddWithValue("@PromoTypeCode", SearchKey.PromoTypeCode);
                }

                SQL += "ORDER BY " + SortField + " ";
                SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC ";
                SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " ";

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                return dt;		
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}		
Exemplo n.º 12
0
		public PromoDetails Details(Int64 PromoID)
		{
			try
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;

				string SQL=	"SELECT " +
								"PromoID, " +
								"PromoCode, " +
								"PromoName, " +
								"StartDate, " +
								"EndDate, " +
								"Status, " +
								"a.PromoTypeID, " +
								"PromoTypeCode, " +
								"PromoTypeName " +
							"FROM tblPromo a " +
							"INNER JOIN tblPromoType b ON a.PromoTypeID = b.PromoTypeID " +
							"WHERE a.PromoID = @PromoID;";

                cmd.Parameters.AddWithValue("@PromoID", PromoID);

                cmd.CommandText = SQL;
                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                PromoDetails Details = new PromoDetails();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.PromoID = Int64.Parse(dr["PromoID"].ToString());
                    Details.PromoCode = "" + dr["PromoCode"].ToString();
                    Details.PromoName = "" + dr["PromoName"].ToString();
                    Details.StartDate = DateTime.Parse(dr["StartDate"].ToString());
                    Details.EndDate = DateTime.Parse(dr["EndDate"].ToString());
                    Details.PromoTypeID = Int32.Parse(dr["PromoTypeID"].ToString());
                    Details.PromoTypeCode = "" + dr["PromoTypeCode"].ToString();
                    Details.PromoTypeName = "" + dr["PromoTypeName"].ToString();
                }

				return Details;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}