protected void btnSave_Click(object sender, EventArgs e) { Int64 Result = 0; offers objoffers = new offers(); objoffers.title = txtSchemeName.Text; objoffers.descp = txtDescription.Text; objoffers.validfrom = txtValidFrom.Text; objoffers.validto = txtValidTo.Text; if (ViewState["fileName"] != null) { objoffers.imagename = ViewState["fileName"].ToString(); } if (Request.QueryString["id"] != null) { objoffers.offerid = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)); Result = (new Cls_offers_b().Update(objoffers)); if (Result > 0) { Clear(); Response.Redirect(Page.ResolveUrl("~/manageoffer.aspx?mode=u")); } else { Clear(); spnMessgae.Style.Add("color", "red"); spnMessgae.InnerText = "Offer Not Updated"; BindOffer(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true))); } } else { Result = (new Cls_offers_b().Insert(objoffers)); if (Result > 0) { SendNotification(objoffers.title, objoffers.imagename, objoffers.descp, objoffers.validfrom, objoffers.validto); txtDescription.Text = string.Empty; txtSchemeName.Text = string.Empty; txtValidFrom.Text = string.Empty; txtValidTo.Text = string.Empty; Response.Redirect(Page.ResolveUrl("~/manageoffer.aspx?mode=i")); } else { Clear(); spnMessgae.Style.Add("color", "red"); spnMessgae.InnerText = "Offer Not Inserted"; } } }
public offers SelectById(Int64 offerid) { SqlDataAdapter da; DataSet ds = new DataSet(); offers objoffers = new offers(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "offers_SelectById"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; cmd.Parameters.AddWithValue("@offerid", offerid); ConnectionString.Open(); da = new SqlDataAdapter(cmd); da.Fill(ds); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0] != null) { if (ds.Tables[0].Rows.Count > 0) { { objoffers.offerid = Convert.ToInt64(ds.Tables[0].Rows[0]["offerid"]); objoffers.title = Convert.ToString(ds.Tables[0].Rows[0]["title"]); objoffers.descp = Convert.ToString(ds.Tables[0].Rows[0]["descp"]); objoffers.imagename = Convert.ToString(ds.Tables[0].Rows[0]["imagename"]); objoffers.validfrom = Convert.ToString(ds.Tables[0].Rows[0]["validfrom"]); objoffers.validto = Convert.ToString(ds.Tables[0].Rows[0]["validto"]); } } } } } } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(null); } finally { ConnectionString.Close(); } return(objoffers); }
public ActionResult Addoffers(offers o) { if (ModelState.IsValid) { db.offers.Add(o); db.SaveChanges(); Session["offer"] = "OFFERS added Suceesfully"; ModelState.Clear(); return(View()); } return(View()); }
public static string GetJSon_Obj() { string ErrMsg = ""; try { List <offers> lstobjoffers = new List <offers>(); { string strSql = ""; strSql = @"select OfferID, OfferCode, OfferName, OfferDescription, Offertype, I.ItemName,Price, CASE Active when 'Y' then 'Yes' else 'No' end as Active from offers O, Items I where O.ItemID = I.ItemID"; if (ErrMsg != string.Empty) { clsCommon.ErrorAlertBox(ErrMsg); return(""); } using (DataTable dtList = clsDatabase.GetDT(strSql, ref ErrMsg)) { if (ErrMsg != string.Empty) { clsCommon.ErrorAlertBox(ErrMsg); return(""); } if ((dtList.Rows.Count > 0)) { rowcount = dtList.Rows.Count; foreach (DataRow r in dtList.Rows) { offers objManageoffers = new offers(); objManageoffers.OfferID = r["OfferID"].ToString().Trim(); objManageoffers.OfferCode = r["OfferCode"].ToString().Trim(); objManageoffers.OfferName = r["OfferName"].ToString().Trim(); objManageoffers.OfferDescription = r["OfferDescription"].ToString().Trim(); objManageoffers.Offertype = r["Offertype"].ToString().Trim(); objManageoffers.ItemName = r["ItemName"].ToString().Trim(); objManageoffers.Price = r["Price"].ToString().Trim(); objManageoffers.Active = r["Active"].ToString().Trim(); lstobjoffers.Add(objManageoffers); } } } } return(JsonConvert.SerializeObject(lstobjoffers)); } catch { return(""); } }
public ActionResult insertoffer(offers o) { SqlConnection con = new SqlConnection(); //con.ConnectionString = "Data Source=souqzone.database.windows.net;Initial Catalog=souqzone;Integrated Security=False;User ID=souqzone_admin;Password=Az@00000;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; con.ConnectionString = @"Data Source=DESKTOP-J0TTRBH\SQLEXPRESS;Initial Catalog=test99;Integrated Security=True"; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = con;//بربط ال command على الداتابيز cmd.CommandText = "insert into offers values('" + o.description + "','" + o.location + "'," + o.packageID + ")"; int x = cmd.ExecuteNonQuery(); con.Close(); return(RedirectToAction("Index2", new { shopOnwerId = int.Parse(Session["shopOwnerID"].ToString()) })); //return View(o); }
public ActionResult Updateoffer(offers o) { SqlConnection con = new SqlConnection(); //con.ConnectionString = "Data Source=souqzone.database.windows.net;Initial Catalog=souqzone;Integrated Security=False;User ID=souqzone_admin;Password=Az@00000;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; con.ConnectionString = @"Data Source=DESKTOP-J0TTRBH\SQLEXPRESS;Initial Catalog=test99;Integrated Security=True"; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = con;//بربط ال command على الداتابيز cmd.CommandText = "update offers set description='" + o.description + "' , location='" + o.location + "' where offerID=" + o.offerID; int xc = cmd.ExecuteNonQuery(); con.Close(); return(RedirectToAction("Index", new { idd = o.supplierID })); //return View(o); }
public Int64 Update(offers objoffers) { Int64 result = 0; try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "offers_Update"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; SqlParameter param = new SqlParameter(); param.ParameterName = "@offerid"; param.Value = objoffers.offerid; param.SqlDbType = SqlDbType.BigInt; param.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(param); cmd.Parameters.AddWithValue("@title", objoffers.title); cmd.Parameters.AddWithValue("@descp", objoffers.descp); cmd.Parameters.AddWithValue("@imagename", objoffers.imagename); cmd.Parameters.AddWithValue("@validfrom", objoffers.validfrom); cmd.Parameters.AddWithValue("@validto", objoffers.validto); ConnectionString.Open(); cmd.ExecuteNonQuery(); result = Convert.ToInt64(param.Value); } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(result); } finally { ConnectionString.Close(); } return(result); }
public ActionResult Editoffers(offers o, transaction_table t) { if (ModelState.IsValid) { t.mpin = "1122"; t.operators_ = o.Network; t.Transaction_Name = "Special Offers"; t.Type = o.Network; t.time = System.DateTime.Now.ToShortTimeString(); t.date = System.DateTime.Now.ToShortDateString(); t.offer_recharge_consumer_numbers = o.Reciever_Mobile_No; t.paymentmethod = o.Payment_Methods; db.transaction_table.Add(t); if (db.SaveChanges() > 0) { o.Transaction_name = string.Empty; o.Type = o.Network; o.Payment_Methods = string.Empty; o.amount = string.Empty; o.Reciever_Mobile_No = string.Empty; o.account_no = string.Empty; db.Entry(o).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ModelState.Clear(); Session["offers"] = "OFFER GETTED SUCCESSFULLY"; } } else { Session["OFF"] = "*ALL FIELDS MUST FILLED"; } return(View()); }
private void BindOffer(Int64 OfferId) { offers objoffers = (new Cls_offers_b().SelectById(OfferId)); if (objoffers != null) { txtSchemeName.Text = objoffers.title; txtDescription.Text = objoffers.descp; txtValidFrom.Text = objoffers.validfrom; txtValidTo.Text = objoffers.validto; if (!string.IsNullOrEmpty(objoffers.imagename)) { imgCategory.Visible = true; ViewState["fileName"] = objoffers.imagename; imgCategory.ImageUrl = offerFrontPath + objoffers.imagename; btnImageUpload.Visible = false; btnRemove.Visible = true; } else { btnImageUpload.Visible = true; } } }
public string Delete(string token) { token = TokenManager.readToken(HttpContext.Current.Request); string message = ""; var strP = TokenManager.GetPrincipal(token); if (strP != "0") //invalid authorization { return(TokenManager.GenerateToken(strP)); } else { int offerId = 0; int userId = 0; Boolean final = false; IEnumerable <Claim> claims = TokenManager.getTokenClaims(token); foreach (Claim c in claims) { if (c.Type == "itemId") { offerId = int.Parse(c.Value); } else if (c.Type == "userId") { userId = int.Parse(c.Value); } else if (c.Type == "final") { final = bool.Parse(c.Value); } } if (final) { try { using (incposdbEntities entity = new incposdbEntities()) { offers offerObj = entity.offers.Find(offerId); entity.offers.Remove(offerObj); message = entity.SaveChanges().ToString(); return(TokenManager.GenerateToken(message)); } } catch { message = "0"; return(TokenManager.GenerateToken(message)); } } else { try { using (incposdbEntities entity = new incposdbEntities()) { offers offerObj = entity.offers.Find(offerId); offerObj.isActive = 0; offerObj.updateUserId = userId; offerObj.updateDate = DateTime.Now; message = entity.SaveChanges().ToString(); return(TokenManager.GenerateToken(message)); } } catch { message = "0"; return(TokenManager.GenerateToken(message)); } } } }
public string Save(string token) { token = TokenManager.readToken(HttpContext.Current.Request); string message = ""; var strP = TokenManager.GetPrincipal(token); if (strP != "0") //invalid authorization { return(TokenManager.GenerateToken(strP)); } else { string offerObject = ""; offers newObject = null; IEnumerable <Claim> claims = TokenManager.getTokenClaims(token); foreach (Claim c in claims) { if (c.Type == "itemObject") { offerObject = c.Value.Replace("\\", string.Empty); offerObject = offerObject.Trim('"'); newObject = JsonConvert.DeserializeObject <offers>(offerObject, new IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" }); break; } } if (newObject.updateUserId == 0 || newObject.updateUserId == null) { Nullable <int> id = null; newObject.updateUserId = id; } if (newObject.createUserId == 0 || newObject.createUserId == null) { Nullable <int> id = null; newObject.createUserId = id; } try { using (incposdbEntities entity = new incposdbEntities()) { offers oldObject = new offers(); var offerEntity = entity.Set <offers>(); if (newObject.offerId == 0) { newObject.updateDate = newObject.createDate; oldObject = offerEntity.Add(newObject); entity.SaveChanges(); message = oldObject.offerId.ToString(); return(TokenManager.GenerateToken(message)); } else { oldObject = entity.offers.Where(p => p.offerId == newObject.offerId).FirstOrDefault(); oldObject.name = newObject.name; oldObject.code = newObject.code; oldObject.discountType = newObject.discountType; oldObject.discountValue = newObject.discountValue; oldObject.startDate = newObject.startDate; oldObject.endDate = newObject.endDate; oldObject.updateDate = newObject.updateDate; oldObject.updateUserId = newObject.updateUserId; oldObject.notes = newObject.notes; oldObject.isActive = newObject.isActive; entity.SaveChanges(); message = oldObject.offerId.ToString(); return(TokenManager.GenerateToken(message)); } } } catch { message = "0"; } } return(TokenManager.GenerateToken(message)); }