protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { ProductLotBL objProductLotBL = new ProductLotBL(); ProductLotEL objProductLotEL = new ProductLotEL(); string Responsetxt = string.Empty; string productimages = Request["hdnimagefiles"]; objProductLotEL.ProductUsed = ItemUsed.SelectedItem.ToString(); if (!categotyLevel2.Visible) { objProductLotEL.CategoryId = Convert.ToInt32(categotyLevel1.SelectedValue); } else { if (categotyLevel3.Visible) { objProductLotEL.CategoryId = Convert.ToInt32(categotyLevel3.SelectedValue); } else { objProductLotEL.CategoryId = Convert.ToInt32(categotyLevel2.SelectedValue); } } objProductLotEL.AuctionId = Convert.ToInt32(auction.SelectedValue); objProductLotEL.IsBranded = rdbYes.Checked; objProductLotEL.Title = txtTitle.Text; objProductLotEL.SKU = txtSKU.Text; objProductLotEL.Description = txtDesc.Text; objProductLotEL.Question = txtQuestion.Text; objProductLotEL.Quantity = Convert.ToInt32(txtQuantity.Text); objProductLotEL.CostBasis = txtCost.Text; objProductLotEL.RetailPrice = txtRetail.Text; objProductLotEL.BuyPrice = txtBuy.Text; objProductLotEL.StartingBid = txtStartBid.Text; objProductLotEL.ShipCountry = ddlCountry.Text; objProductLotEL.ShipWithin = ddlShipWithin.Text; objProductLotEL.DeliveryTime = ddlTimeTake.Text; objProductLotEL.IsFreeShipping = chkFreeShipping.Checked; objProductLotEL.ShippingPrice = ddlPrice.Text; objProductLotEL.IsShippedEverywhere = chkShip.Checked; objProductLotEL.LowEstimatePrice = lowEstimatePrice.Text; objProductLotEL.HighEstimatePrice = highEstimatePrice.Text; objProductLotEL.LiveAuctionPassed = "0"; objProductLotEL.FairWarning = false; objProductLotEL.IsSold = false; objProductLotEL.images = productimages; if (objProductLotBL.Save(objProductLotEL, out Responsetxt)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration", "alert('" + Responsetxt + "');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration", "alert('" + Responsetxt + "');", true); } } }
protected void Upload(object sender, EventArgs e) { #region UpLoadCSV //Upload and save the file if (CSVFileUpload.HasFile) { string filename = DateTime.Now.ToString("yyyy_MM_ddTHHmmss") + "_" + Path.GetFileName(CSVFileUpload.FileName); string csvPath = Server.MapPath("~/fileupload/CSV/") + filename; CSVFileUpload.SaveAs(csvPath); DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[5] { new DataColumn("Number", typeof(string)), new DataColumn("LotDesc", typeof(string)), new DataColumn("LowEstimatePrice", typeof(string)), new DataColumn("HighEstimatePrice", typeof(string)), new DataColumn("SaleSection", typeof(string)) }); string csvData = File.ReadAllText(csvPath); foreach (string row in csvData.Split('\n')) { try { if (!string.IsNullOrEmpty(row)) { dt.Rows.Add(); int i = 0; foreach (string cell in row.Split(',')) { dt.Rows[dt.Rows.Count - 1][i] = cell; i++; } } } catch (Exception) { Response.Write("<script type='text/javascript'>alert('There might be a problem in uploading the file.Please try again !');</script>"); } } /*--------- proc call ---------- */ ProductLotBL objProductLotBL = new ProductLotBL(); ProductLotEL objProductLotEL = new ProductLotEL(); string Responsetxt = string.Empty; string productimages = Request["hdnimagefiles"]; ArrayList images = new ArrayList(); foreach (string image in productimages.Split(',')) { images.Add(image); } Response.Write(images.Count); /*--------- proc call end -------*/ string connectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnStr"]; using (SqlConnection con = new SqlConnection(connectionString)) { try { for (int i = 1; i < dt.Rows.Count; i++) { var category = Convert.ToString(dt.Rows[i]["SaleSection"]).Trim(); string CategoryQuery = "select * from ProductCategory where CategoryName like '" + category + "'"; SqlDataAdapter adapter = new SqlDataAdapter(CategoryQuery, con); DataTable dtCategory = new DataTable(); adapter.Fill(dtCategory); objProductLotEL.ProductUsed = ""; objProductLotEL.CategoryId = Convert.ToInt32(dtCategory.Rows[0]["CategoryId"]); objProductLotEL.AuctionId = Convert.ToInt32(auction.SelectedValue); objProductLotEL.IsBranded = true; objProductLotEL.Title = ""; objProductLotEL.SKU = ""; objProductLotEL.Description = Convert.ToString(dt.Rows[i]["LotDesc"]); objProductLotEL.Question = ""; objProductLotEL.Quantity = 1; objProductLotEL.CostBasis = ""; objProductLotEL.RetailPrice = ""; objProductLotEL.BuyPrice = ""; objProductLotEL.StartingBid = ""; objProductLotEL.ShipCountry = ""; objProductLotEL.ShipWithin = ""; objProductLotEL.DeliveryTime = ""; objProductLotEL.IsFreeShipping = true; objProductLotEL.ShippingPrice = ""; objProductLotEL.IsShippedEverywhere = true; objProductLotEL.IsScheduled = true; objProductLotEL.images = Convert.ToString(images[i - 1]); objProductLotEL.LowEstimatePrice = Convert.ToString(dt.Rows[i]["LowEstimatePrice"]); objProductLotEL.HighEstimatePrice = Convert.ToString(dt.Rows[i]["HighEstimatePrice"]); if (objProductLotBL.Save(objProductLotEL, out Responsetxt)) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration", "alert('" + Responsetxt + "');", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration", "alert('" + Responsetxt + "');", true); } } } catch (Exception) { Response.Write("<script type='text/javascript'>alert('There might be a problem in uploading the file.Please try again !');</script>"); } } } #endregion }
public bool Save(ProductLotEL productLotEL, out string Responcetxt) { ProcedureExecute proc; bool Res = false; string strError = string.Empty; try { using (proc = new ProcedureExecute("prcProductLot")) { proc.AddVarcharPara("@Action", 100, "Save"); proc.AddVarcharPara("@ProductUsed", 200, productLotEL.ProductUsed); proc.AddIntegerPara("@CategoryId", productLotEL.CategoryId); proc.AddIntegerPara("@AuctionId", productLotEL.AuctionId); proc.AddBooleanPara("@IsBranded", productLotEL.IsBranded); proc.AddVarcharPara("@Title", 200, productLotEL.Title); proc.AddVarcharPara("@SKU", 200, productLotEL.SKU); proc.AddVarcharPara("@Description", 200, productLotEL.Description); proc.AddVarcharPara("@Question", 200, productLotEL.Question); proc.AddIntegerPara("@Quantity", productLotEL.Quantity); proc.AddVarcharPara("@CostBasis", 200, productLotEL.CostBasis); proc.AddVarcharPara("@RetailPrice", 200, productLotEL.RetailPrice); proc.AddVarcharPara("@BuyPrice", 200, productLotEL.BuyPrice); proc.AddVarcharPara("@StartingBid", 200, productLotEL.StartingBid); proc.AddVarcharPara("@ShipWithin", 200, productLotEL.ShipWithin); proc.AddVarcharPara("@DeliveryTime", 200, productLotEL.DeliveryTime); proc.AddVarcharPara("@ShipCountry", 200, productLotEL.ShipCountry); proc.AddVarcharPara("@ShippingPrice", 200, productLotEL.ShippingPrice); proc.AddBooleanPara("@IsFreeShipping", productLotEL.IsFreeShipping); proc.AddBooleanPara("@IsShippedEverywhere", productLotEL.IsShippedEverywhere); proc.AddBooleanPara("@IsScheduled", productLotEL.IsScheduled); proc.AddVarcharPara("@Images", 800, productLotEL.images); proc.AddNVarcharPara("@ReturnValue", 500, productLotEL.ReturnValue, QueryParameterDirection.Output); proc.AddVarcharPara("@LowEstimatePrice", 200, productLotEL.LowEstimatePrice); proc.AddVarcharPara("@HighEstimatePrice", 200, productLotEL.HighEstimatePrice); proc.AddVarcharPara("@LiveAuctionPassed", 200, productLotEL.LiveAuctionPassed); proc.AddBooleanPara("@FairWarning", productLotEL.FairWarning); proc.AddBooleanPara("@IsSold", productLotEL.IsSold); int i = proc.RunActionQuery(); if (i > 0) { Res = true; productLotEL.ProductLotId = Convert.ToInt32(proc.GetParaValue("@ReturnValue")); strError = "Item added successfully."; } else { strError = Convert.ToString(proc.GetParaValue("@ReturnValue")); } Responcetxt = strError; return(Res); } } catch (Exception ex) { throw ex; } finally { proc = null; } }