private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { roweditortarget.Controls.Clear(); BoxRowEditor boxy = new BoxRowEditor(); roweditortarget.Controls.Add(boxy); boxy.Dock = DockStyle.Fill; string property = listBox1.SelectedItem.ToString(); if (property != "") { // Now we parse the dataset that contains format information and // try to find the "property" string fullproperty = "{box}" + property; // look for presence of {box} style // before looking for subelements // iterate thru and look for all formats foreach (DataRow row in dt2.Rows) { // * You must add one {box}label as an empty row in Format table string sanitize = row[0].ToString(); int id = sanitize.IndexOf(fullproperty); if (id > -1) { // found this style BoxDetail box = setuptablevaluebox(sanitize); boxy.SetDetails(box); } } } } }
public bool Insert(BoxDetail model) { try { if (model != null) { var update = context.BoxDetail.Where(x => x.BoxDetailID == model.BoxDetailID).FirstOrDefault(); if (update != null) { update.MCameraTypeID = model.MCameraTypeID; update.MOptionID = model.MOptionID; update.OptionValue = model.OptionValue; update.UpdBy = model.UpdBy; update.UpdDateTime = DateTime.Now; } else { model.InsDateTime = DateTime.Now; context.BoxDetail.Add(model); } context.SaveChanges(); } } catch (Exception e) { var joke = e.Message.ToString(); return(false); } return(true); }
/// <summary> /// Handles the result. /// </summary> /// <param name="canadaPostResponse">The response from Canada Post.</param> /// /// <param name="language">The language.</param> /// <returns></returns> private RequestResult HandleResult(string canadaPostResponse, CanadaPostLanguageEnum language) { var result = new RequestResult(); if (String.IsNullOrEmpty(canadaPostResponse)) { result.IsError = true; result.StatusCode = 0; result.StatusMessage = "Unable to connect to Canada Post."; return(result); } var doc = new XmlDocument(); doc.LoadXml(canadaPostResponse); XElement resultRates = XElement.Load(new StringReader(canadaPostResponse)); IEnumerable <XElement> query; // if we have any errors if (doc.GetElementsByTagName("error").Count > 0) { // query using LINQ the "error" node in the XML query = from errors in resultRates.Elements("error") select errors; XElement error = query.First(); if (error != null) { // set the status code information of the request result.StatusCode = Convert.ToInt32(error.Element("statusCode").Value); result.StatusMessage = error.Element("statusMessage").Value; result.IsError = true; } } else { // query using LINQ the "ratesAndServicesResponse" node in the XML because it contains // the actual status code information query = from response in resultRates.Elements("ratesAndServicesResponse") select response; XElement info = query.First(); // if we have informations if (info != null) { // set the status code information of the request result.StatusCode = Convert.ToInt32(info.Element("statusCode").Value); result.StatusMessage = info.Element("statusMessage").Value; // query using LINQ all the returned "product" nodes in the XML query = from prod in resultRates.Elements("ratesAndServicesResponse").Elements("product") select prod; foreach (XElement product in query) { // set the information related to this available rate var rate = new DeliveryRate(); rate.Sequence = Convert.ToInt32(product.Attribute("sequence").Value); rate.Name = product.Element("name").Value; rate.Amount = Convert.ToDecimal(product.Element("rate").Value, new CultureInfo("en-US", false).NumberFormat); DateTime shipDate; if (DateTime.TryParse(product.Element("shippingDate").Value, out shipDate) == true) { rate.ShippingDate = shipDate; } DateTime delivDate; if (DateTime.TryParse(product.Element("deliveryDate").Value, out delivDate) == true) { CultureInfo culture; if (language == CanadaPostLanguageEnum.French) { culture = new CultureInfo("fr-ca"); rate.DeliveryDate = delivDate.ToString("d MMMM yyyy", culture); } else { culture = new CultureInfo("en-us"); rate.DeliveryDate = delivDate.ToString("MMMM d, yyyy", culture); } } else { //rate.DeliveryDate = product.Element("deliveryDate").Value; rate.DeliveryDate = string.Empty; } result.AvailableRates.Add(rate); } query = from packing in resultRates.Elements("ratesAndServicesResponse").Elements("packing").Elements("box") select packing; foreach (XElement packing in query) { var box = new BoxDetail(); box.Name = packing.Element("name").Value; box.Weight = Convert.ToDouble(packing.Element("weight").Value, new CultureInfo("en-US", false).NumberFormat); box.ExpediterWeight = Convert.ToDouble(packing.Element("expediterWeight").Value, new CultureInfo("en-US", false).NumberFormat); box.Length = Convert.ToDouble(packing.Element("length").Value, new CultureInfo("en-US", false).NumberFormat); box.Width = Convert.ToDouble(packing.Element("width").Value, new CultureInfo("en-US", false).NumberFormat); box.Height = Convert.ToDouble(packing.Element("height").Value, new CultureInfo("en-US", false).NumberFormat); box.Quantity = Convert.ToInt32(packing.Element("packedItem").Element("quantity").Value); // add the box to the result result.Boxes.Add(box); } } } return(result); }
public bool Update(int id, BoxDetail model) { throw new NotImplementedException(); }
public bool Insert(BoxDetail model) { return(boxDetailRepository.Insert(model)); }
public IHttpActionResult PostBoxDetail(BoxDetail obj) { return(Ok(boxDetailService.Insert(obj))); }
/// <summary> /// /// </summary> /// <param name="c"></param> private BoxDetail setuptablevaluebox(string c) { string keyword = ""; BoxDetail r = new BoxDetail(c); object value = dt2.Rows.Find(keyword + c + "color"); if (value != null) { Color cr = Color.Orange; object value2 = (value as DataRow)[1]; if (value2 != null) { cr = Color.FromArgb((int)value2); r.boxfillcolor = cr; } } value = dt2.Rows.Find(keyword + c + "thick"); if (value != null) { int cr = 11; object value2 = (value as DataRow)[1]; if (value2 != null) { cr = ((int)value2); r.boxthickness = cr; } } value = dt2.Rows.Find(keyword + c + "gradient"); if (value != null) { int cr = 0; object value2 = (value as DataRow)[1]; if (value2 != null) { cr = ((int)value2); r.gradient = cr; object value3 = (value as DataRow)[2]; int value3i = 0; Int32.TryParse(value3.ToString(), out value3i); //value3 = 0; if (value3 != null) { r.gradientColor = Color.FromArgb(value3i); } } } value = dt2.Rows.Find(keyword + c + "boxtype"); if (value != null) { int cr = 11; object value2 = (value as DataRow)[1]; if (value2 != null) { cr = ((int)value2); r.boxType = (BoxType)cr; } } r.primaryFont = UpdateBoxForFonts(r.primaryFont, c, "font", keyword); r.secondaryFont = UpdateBoxForFonts(r.primaryFont, c, "secondaryfont", keyword); return(r); }
private void Bindings() { // bind the ints // colors are harder and custom on each clicker nudLineWidth.DataBindings.Clear(); nudLineWidth.DataBindings.Add(new Binding("value", dt2.DefaultView[0], "valueprop")); nudFontSize.DataBindings.Clear(); nudFontSize.DataBindings.Add(new Binding("value", dt2.DefaultView[1], "valueprop")); nudVerticalSpace.DataBindings.Clear(); nudVerticalSpace.DataBindings.Add(new Binding("value", dt2.DefaultView[d_verticalspace], "valueprop")); nudHorizontalSpace.DataBindings.Clear(); nudHorizontalSpace.DataBindings.Add(new Binding("value", dt2.DefaultView[d_hspace], "valueprop")); nudMargin.DataBindings.Clear(); nudMargin.DataBindings.Add(new Binding("value", dt2.DefaultView[d_margin], "valueprop")); nudBoxHeight.DataBindings.Clear(); nudBoxHeight.DataBindings.Add(new Binding("value", dt2.DefaultView[d_boxheight], "valueprop")); nudBoxWidth.DataBindings.Clear(); nudBoxWidth.DataBindings.Add(new Binding("value", dt2.DefaultView[d_boxwidth], "valueprop")); // set default colors myTree.BoxFillColor = Color.FromArgb((int)dt2.Rows[d_BoxFillColor][1]); myTree.FontColor = Color.FromArgb((int)dt2.Rows[d_fontcolor][1]); myTree.LineColor = Color.FromArgb((int)dt2.Rows[d_linecolor][1]); myTree.BGColor = Color.FromArgb((int)dt2.Rows[d_bgcolor][1]); DataColumn[] keys = new DataColumn[1]; keys[0] = dt2.Columns[0]; dt2.PrimaryKey = keys; myTree.format.boxlinewidth = setuptablevalueint("boxlinewidth"); myTree.format.secondline_color = setuptablevaluecolor("secondline_color"); myTree.format.secondline_thick = setuptablevalueint("secondline_thick"); myTree.format.secondaryFontColor = setuptablevaluecolor("secondaryFontColor"); myTree.format.secondaryFontName = setuptablevaluestring("secondaryFontName"); myTree.format.calloutboxcolor = setuptablevaluecolor("calloutboxcolor"); // myTree.format.xmarginextra = setuptablevalueint("xmarginextra"); Set only via scripting int size = setuptablevalueint("secondaryFontSize"); if (size > 0) { myTree.format.secondaryFontSize = size; } //myTree.format.actionbox = setuptablevaluebox("actionbox"); //myTree.format.outcomebox = setuptablevaluebox("outcomebox"); //myTree.format.defaultbox = setuptablevaluebox("defaultbox"); myTree.format.boxes.Clear(); // iterate thru and look for all formats foreach (DataRow row in dt2.Rows) { // * You must add one {box}label as an empty row in Format table string sanitize = row[0].ToString(); int id = sanitize.IndexOf("{box}"); if (id > -1) { sanitize = sanitize.Substring(id + 1 + 4, sanitize.Length - id - 1 - 4); BoxDetail box = setuptablevaluebox(sanitize); myTree.format.boxes.Add(box); } } /* * TreeBuilderSimple.BoxDetail box = setuptablevaluebox("actionbox"); * myTree.format.boxes.Add(box); * box = setuptablevaluebox("outcomebox"); * myTree.format.boxes.Add(box); * box = setuptablevaluebox("defaultbox"); * myTree.format.boxes.Add(box); */ button1.Font = new Font(dt2.DefaultView[d_fontname][2].ToString(), float.Parse(dt2.DefaultView[1][1].ToString())); myTree.FontName = button1.Font.Name; }