public bool AddShutterEstimate(shutters shutter) { System.Xml.Linq.XElement customerLocationPics = new System.Xml.Linq.XElement("root"); foreach (var r in shutter.CustomerLocationPics) { var varPics = new System.Xml.Linq.XElement("pics", new System.Xml.Linq.XElement("pic", r.LocationPicture)); customerLocationPics.Add(varPics); } shutter.locationpicture = customerLocationPics.ToString(); System.Xml.Linq.XElement shutterAccessoriesList = new System.Xml.Linq.XElement("root"); foreach (var r in shutter.ShutterAccessories) { if (r.accessories != null) { var varPics = new System.Xml.Linq.XElement("accessories", new System.Xml.Linq.XElement("accessorie", "<![CDATA[" + r.accessories + "]]> "), new System.Xml.Linq.XElement("qty", r.quantity)); shutterAccessoriesList.Add(varPics); } } shutter.ShutterAccessorie = shutterAccessoriesList.ToString(); return(shuttersDAL.Instance.AddShutterEstimate(shutter)); }
public bool AddShutterEstimate(shutters objshutter) { int result = 0; try { SqlDatabase database = MSSQLDataBase.Instance.GetDefaultDatabase(); { DbCommand command = database.GetStoredProcCommand("UDP_AddShutterEstimate"); command.CommandType = CommandType.StoredProcedure; database.AddInParameter(command, "@estimateId", DbType.Int32, objshutter.estimateID); database.AddInParameter(command, "@CustomerId", DbType.String, objshutter.CustomerId); database.AddInParameter(command, "@UserId", DbType.String, objshutter.UserId); database.AddInParameter(command, "@ShutterId", DbType.Int32, objshutter.ShutterId); database.AddInParameter(command, "@ShutterTopId", DbType.Int32, objshutter.ShutterTopId); database.AddInParameter(command, "@ShutterWidthId", DbType.Int32, objshutter.ShutterWidthId); database.AddInParameter(command, "@ShutterLength", DbType.String, objshutter.height); database.AddInParameter(command, "@ShutterColorId", DbType.Int32, objshutter.ColorCode); database.AddInParameter(command, "@Quantity", DbType.Int32, objshutter.quantity); database.AddInParameter(command, "@SurfaceMount", DbType.Int32, objshutter.surfaceofmount); database.AddInParameter(command, "@Workarea", DbType.String, objshutter.workarea); database.AddInParameter(command, "@Style", DbType.Int32, objshutter.quantity); database.AddInParameter(command, "@Spcl_instr", DbType.String, objshutter.specialinstructions); //database.AddInParameter(command, "@Loc_Pic", DbType.String, "~/CustomerDocs/LocationPics/" + objshutter.MainImage); database.AddInParameter(command, "@Loc_Pic", DbType.String, objshutter.MainImage); database.AddInParameter(command, "@ProductTypeId", DbType.Int32, objshutter.ProductType); database.AddInParameter(command, "@LocationPicsXml", DbType.Xml, objshutter.locationpicture); database.AddInParameter(command, "@ShuttersEstimateAccXml", DbType.Xml, objshutter.ShutterAccessorie); database.AddOutParameter(command, "@result", DbType.Int32, 1); database.ExecuteNonQuery(command); result = Convert.ToInt32(database.GetParameterValue(command, "@result")); } } catch (Exception ex) { //LogManager.Instance.WriteToFlatFile(ex); return(false); } return(result > JGConstant.RETURN_ZERO ? JGConstant.RETURN_TRUE : JGConstant.RETURN_FALSE); }
//Save on Shutter... protected void btnsave_Click(object sender, EventArgs e) { try { string filename; //List<string> locationpics = new List<string>(); shutters objshutter = new shutters(); if (ddlColor.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please select Color.')", true); return; } if (Request.QueryString[QueryStringKey.Key.ProductId.ToString()] != null) { objshutter.estimateID = Convert.ToInt32(Request.QueryString[QueryStringKey.Key.ProductId.ToString()]); } else { objshutter.estimateID = 0; } objshutter.ProductType = Convert.ToInt32(hidProdType.Value); objshutter.CustomerNm = txtCustomer.Text; //objshutter.CustomerId = Convert.ToInt32(Session["CustomerId"]); // if (Session[SessionKey.Key.CustomerId.ToString()] != null) //{ objshutter.CustomerId = Convert.ToInt16(Request.QueryString[1]);//Convert.ToInt32(Session[SessionKey.Key.CustomerId.ToString()]); //} objshutter.ShutterId = Convert.ToInt32(ddlshuttername.SelectedValue); objshutter.ShutterName = ddlshuttername.Text; objshutter.ShutterTopId = Convert.ToInt32(ddlShutterTop.SelectedValue); objshutter.Shutters_top = ddlShutterTop.Text; objshutter.workarea = txtWork_area.Text; List <CustomerLocationPic> pics = (List <CustomerLocationPic>)ViewState[SessionKey.Key.PagedataTable.ToString()]; var image = pics.AsEnumerable().Take(1); string mainImage = image.FirstOrDefault().LocationPicture; objshutter.CustomerLocationPics = pics; objshutter.MainImage = mainImage; objshutter.ColorCode = ddlColor.SelectedValue.ToString(); objshutter.Color = ddlColor.Text; List <Shutter_accessories> lstaccessorie = new List <Shutter_accessories>(); Shutter_accessories accessories = new Shutter_accessories(); accessories.accessories = ddlaccessories.Text; accessories.quantity = Convert.ToInt32(txtqty.Text); lstaccessorie.Add(accessories); int value = Convert.ToInt32(hdncount.Value); for (int i = 1; i <= value; i++) { Shutter_accessories item = new Shutter_accessories(); string accessorie = "accessories" + i.ToString(); string qty = "qty" + i.ToString(); if (Request.Form[accessorie] != null) { item.accessories = Request.Form[accessorie].ToString(); item.quantity = Convert.ToInt32(Request.Form[qty].ToString()); lstaccessorie.Add(item); } } objshutter.ShutterAccessories = lstaccessorie; objshutter.surfaceofmount = Convert.ToInt32(ddlSurface_mount.SelectedValue); objshutter.specialinstructions = txtSpcl_inst.Text; objshutter.ShutterWidthId = Convert.ToInt32(ddlWidth.SelectedValue); objshutter.width = ddlWidth.Text; objshutter.height = txtHeight.Text; objshutter.quantity = Convert.ToInt32(txtQuantity.Text); objshutter.UserId = userId; bool result = shuttersBLL.Instance.AddShutterEstimate(objshutter); if (result) { ScriptManager.RegisterStartupScript(this, this.GetType(), "AlertBox", "alert('New Shutter estimate has been added successfully');", true); clearcontrols(); //Response.Redirect("~/Sr_App/ProductEstimate.aspx?CustomerId=" + objshutter.CustomerId); Response.Redirect("~/Sr_App/ProductEstimate.aspx"); } } catch (Exception ex) { logManager.writeToLog(ex, "Custom", Request.ServerVariables["remote_addr"].ToString()); } }