public ActionResult Edit(ECommerceAccount model) { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Edit ECommerce Account"; EditECommerceAccount(model); return(RedirectToAction("Index")); }
public ActionResult Add() { if (Session["UserName"] == null) { return(RedirectToAction("Index", "Account")); } ViewBag.ReportTitle = "Add Ecommerce account"; ECommerceAccount model = new ECommerceAccount(); model.AllStatus = GetSelectListItems((short)Helpers.Helpers.ListType.allStatus); model.AllCompany = GetSelectListItems((short)Helpers.Helpers.ListType.company); model.AllAdmin = GetSelectListItems((short)Helpers.Helpers.ListType.allUser); return(View(model)); }
private ECommerceAccount fillInObject(DataRow dr) { ECommerceAccount account = new ECommerceAccount(); account.id = (int)dr["id"]; account.ebay_account = (string)dr["ebay_account"]; account.ebay_user = (string)dr["ebay_user"]; account.site = (string)dr["site"]; account.admin = new User(); if (dr["AdminID"] != DBNull.Value) { account.StatusID = Int32.Parse(dr["AdminID"].ToString()); account.admin.FirstName = dr["FirstName"].ToString(); account.admin.LastName = dr["LastName"].ToString(); } if (dr["StatusID"] != DBNull.Value) { account.StatusID = Int32.Parse(dr["StatusID"].ToString()); } if (dr["storeid"] != DBNull.Value) { account.storeid = Int32.Parse(dr["storeid"].ToString()); } if (dr["serviceUrl"] != DBNull.Value) { account.serviceUrl = dr["serviceUrl"].ToString(); } if (dr["companyName"] != DBNull.Value) { account.companyName = dr["companyName"].ToString(); } if (dr["site"] != DBNull.Value) { account.site = (string)dr["site"]; } if (dr["lastSyncTime"] != DBNull.Value) { account.lastSyncTime = (DateTime)dr["lastSyncTime"]; } return(account); }
public void AddECommerceAccount(ECommerceAccount model) { using (MySqlConnection connection = new MySqlConnection(Helpers.Helpers.GetERPConnectionString())) { try { // Create the user record. MySqlCommand cmd = new MySqlCommand("", connection); connection.Open(); StringBuilder sb = new StringBuilder(); sb.Append(" insert ebay_account (ebay_account, site, ebay_token, ebay_user,mail, storeid,serviceUrl) "); sb.Append(" value ( "); sb.Append(" '" + model.ebay_account + "',"); sb.Append(" '" + model.site + "',"); sb.Append(" '" + model.ebay_token + "',"); sb.Append(" '" + model.ebay_user + "',"); sb.Append(" '" + model.mail + "',"); sb.Append(" " + model.storeid + ","); sb.Append(" '" + model.serviceUrl + "'"); sb.Append(" ) "); cmd.CommandText = sb.ToString(); int id = cmd.ExecuteNonQuery(); //insert account sb.Clear(); sb.Append("insert tblcompanyebayaccount (CompanyID, startDate, ebayaccountid, statusid, adminid) value "); sb.Append(model.companyId + ",'" + DateTime.Now.ToShortDateString() + "'," + id + "1" + model.adminID); cmd.CommandText = sb.ToString(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { connection.Close(); } } }
public void EditECommerceAccount(ECommerceAccount model) { using (MySqlConnection connection = new MySqlConnection(Helpers.Helpers.GetERPConnectionString())) { try { // Create the user record. MySqlCommand cmd = new MySqlCommand("", connection); connection.Open(); StringBuilder sb = new StringBuilder(); sb.Append(" update ebay_account set "); sb.Append(" ebay_account ='" + model.ebay_account + "',"); sb.Append(" site ='" + model.site + "',"); sb.Append(" ebay_token ='" + model.ebay_token + "',"); sb.Append(" ebay_user ='******',"); sb.Append(" mail ='" + model.mail + "',"); sb.Append(" storeid =" + model.storeid + ","); sb.Append(" serviceUrl ='" + model.serviceUrl + "',"); sb.Append(" where id = " + model.id); cmd.CommandText = sb.ToString(); cmd.ExecuteNonQuery(); //update company id for property sb.Clear(); sb.Append("update tblcompanyebayaccount set CompanyID = " + model.companyId + " where CompanyEbayAccountID=" + model.CompanyEbayAccountID); cmd.CommandText = sb.ToString(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { connection.Close(); } } }