private void Save() { this.advModel.CityId = (this.cmbCity.SelectedItem as CityModel).CityId; this.advModel.ExId = (this.cmbEx.SelectedItem as ExLogisticModel).ExId; double amount = 0; double.TryParse(this.tbAmount.Text, out amount); this.advModel.Amount = amount; if (this.maintainType == MaintainType.New) { var addResult = WebRequestUtil.AddCityExLogisticsAmount(JsonUtil.Serialize(this.advModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建地区快递物流金额失败!"); } } else { var updateResult = WebRequestUtil.UpdateCityExLogisticsAmount(this.advModel.id, JsonUtil.Serialize(this.advModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新地区快递物流金额!"); } } }
private void InitControls() { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns[0].Width = 250; this.dataGridView1.Columns[1].Width = 100; this.dataGridView1.Columns[2].Width = 80; this.dataGridView1.Columns[3].Width = 80; this.dataGridView1.Columns[4].Width = 80; var result = WebRequestUtil.GetBrandHome(); if (result != null) { var response = JsonUtil.Deserialize <QSWResponse <List <BrandModel> > >(result.Content); List <BrandModel> brandModelList = response.Data; foreach (var brand in brandModelList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = brand.BrandName; this.dataGridView1.Rows[index].Cells[1].Value = brand.BrandImg; this.dataGridView1.Rows[index].Cells[2].Value = brand.OderSart; this.dataGridView1.Rows[index].Cells[3].Value = brand.BrandTypeId; this.dataGridView1.Rows[index].Cells[4].Value = brand.BrandState; this.dataGridView1.Rows[index].Tag = brand; } } }
private void InitControls() { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns[0].Width = 250; this.dataGridView1.Columns[1].Width = 250; this.dataGridView1.Columns[2].Width = 80; var result = WebRequestUtil.GetCityExLogisticsAmountList(); if (result != null) { var response = JsonUtil.Deserialize <QSWResponse <List <CityExLogisticsAmountModel> > >(result.Content); if (response != null) { List <CityExLogisticsAmountModel> brandModelList = response.Data; foreach (var brand in brandModelList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = this.GetCityName(brand.CityId); this.dataGridView1.Rows[index].Cells[1].Value = this.GetExName(brand.ExId); this.dataGridView1.Rows[index].Cells[2].Value = brand.Amount; this.dataGridView1.Rows[index].Tag = brand; } } } }
private void InitControls() { this.kryptonDataGridView1.Rows.Clear(); var response = WebRequestUtil.GetAdvList(); if (response != null) { var res = JsonUtil.Deserialize <QSWResponse <List <AdvModel> > >(response.Content); foreach (var adv in res.Data) { int index = this.kryptonDataGridView1.Rows.Add(); this.kryptonDataGridView1.Rows[index].Cells[0].Value = this.GetAdvTypeStr(adv.AdvTypeId); this.kryptonDataGridView1.Rows[index].Cells[1].Value = this.GetAdvContentStr(adv.AdvTypeId, adv.AdvInnerId); this.kryptonDataGridView1.Rows[index].Cells[2].Value = adv.AdvSart; this.kryptonDataGridView1.Rows[index].Cells[3].Value = adv.AdvImage; this.kryptonDataGridView1.Rows[index].Tag = adv; } if (res.Data.Count > 0) { this.kryptonDataGridView1.Rows[0].Selected = false; this.kryptonDataGridView1.Rows[0].Selected = true; } } }
private static List <CommodityTypeModel> getCommodityTypeList() { var contentResult = WebRequestUtil.GetCommodityType(); if (contentResult != null) { var response = JsonUtil.Deserialize <QSWResponse <List <CommodityTypeModel> > >(contentResult.Content); List <CommodityTypeModel> commodityModelList = response.Data; return(commodityModelList); } return(null); }
private static List <UnitModel> getUnitModelList() { var contentResult = WebRequestUtil.GetUnit(); if (contentResult != null) { var response = JsonUtil.Deserialize <QSWResponse <List <UnitModel> > >(contentResult.Content); List <UnitModel> unitModelList = response.Data; return(unitModelList); } return(null); }
private void Save() { if (this.isReplaceImg) { this.advModel.AdvImage = this.advModel.AdvId + Path.GetExtension(imagePath); } else { this.advModel.AdvImage = this.tbAdvImage.Text; } this.advModel.AdvTypeId = (this.cmbAdvType.SelectedItem as AdvTypeModel).AdvTypeId; if (this.advModel.AdvTypeId == 1) { this.advModel.AdvInnerId = (this.cmbAdvContent.SelectedItem as BrandModel).BrandId; } else if (this.advModel.AdvTypeId == 2) { this.advModel.AdvInnerId = (this.cmbAdvContent.SelectedItem as CommodityModel).CommodityId; } else { this.advModel.AdvInnerId = 0; } int order = 0; int.TryParse(this.tbAdvSart.Text, out order); this.advModel.AdvSart = order; if (this.maintainType == MaintainType.New) { var addResult = WebRequestUtil.AddAdv(JsonUtil.Serialize(this.advModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建广告失败!"); } } else { var updateResult = WebRequestUtil.UpdateAdv(this.advModel.AdvId, JsonUtil.Serialize(this.advModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新广告失败!"); } } //replace image if (this.isReplaceImg) { this.ReplaceImage(); } }
private bool ModifyAD(int index, string filePath) { byte[] fileBytes = File.ReadAllBytes(filePath); var response = WebRequestUtil.ReplaceAdsImg(index, Convert.ToBase64String(fileBytes)); if (response != null) { int res = JsonUtil.Deserialize <QSWResponse <string> >(response.Content).Status; return(res == 1); } else { return(false); } }
private void BtnPreview_Click(object sender, EventArgs e) { var response = WebRequestUtil.GetAdsImg(this.comboBox1.SelectedIndex + 1); if (response != null) { var data = JsonUtil.Deserialize <QSWResponse <string> >(response.Content); if (!string.IsNullOrEmpty(data.Data)) { var imgBytes = Convert.FromBase64String(data.Data); string imageFile = SaveToCache(imgBytes); this.pictureBox1.Image = new Bitmap(imageFile); } } }
private void btnDel_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { var commodityType = this.dataGridView1.SelectedRows[0].Tag as CommodityTypeModel; var result = WebRequestUtil.DeleteCommodityType(commodityType.TypeId); if (result != null) { bool res = JsonUtil.Deserialize <QSWResponse <bool> >(result.Content).Data; if (res) { this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]); } } } }
private void ReplaceImge() { string imgName = this.commdodityModel.CommodityImg; //当前图片数量加1 var contentBytes = File.ReadAllBytes(this.tbImg.Text); string imgContent = Convert.ToBase64String(contentBytes); var replaceRes = WebRequestUtil.ReplaceCommodityImg(this.previousImg, imgName, imgContent); if (replaceRes != null) { LogUtil.Info("AddUpdateCommodityFrm.ReplaceImage successfully!"); } else { LogUtil.Error("AddUpdateCommodityFrm.ReplaceImage failed!replaceRes is null!"); } }
private void btnDel_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { var brand = this.dataGridView1.SelectedRows[0].Tag as ExLogisticModel; var deleteResponse = WebRequestUtil.DeleteExLogistic(brand.ExId); if (deleteResponse != null) { bool res = JsonUtil.Deserialize <QSWResponse <bool> >(deleteResponse.Content).Data; if (res) { this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]); } } } }
private void ReplaceImage() { string imgName = this.brandModel.BrandId + "1" + Path.GetExtension(this.tbImage.Text); var contentBytes = File.ReadAllBytes(this.tbImage.Text); string imgContent = Convert.ToBase64String(contentBytes); var replaceRes = WebRequestUtil.ReplaceBrandImg(this.previousImg, imgName, imgContent); if (replaceRes != null) { LogUtil.Info("AddUpdateBrandFrm.ReplaceImage successfully!"); } else { LogUtil.Error("AddUpdateBrandFrm.ReplaceImage failed!replaceRes is null!"); } }
private void ReplaceImage() { string imgName = this.advModel.AdvId + Path.GetExtension(imagePath); var contentBytes = File.ReadAllBytes(imagePath); string imgContent = Convert.ToBase64String(contentBytes); var replaceRes = WebRequestUtil.ReplaceAdsImg(this.previousImg, imgName, imgContent); if (replaceRes != null) { LogUtil.Info("AddUpdateADFrm.ReplaceImage successfully!"); } else { LogUtil.Error("AddUpdateADFrm.ReplaceImage failed!replaceRes is null!"); } }
private void InitControls() { this.dataGridView1.Rows.Clear(); var result = WebRequestUtil.GetCommodityType(); if (result != null) { var commodityTypeList = JsonUtil.Deserialize <QSWResponse <List <CommodityTypeModel> > >(result.Content).Data; foreach (var commodityType in commodityTypeList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = commodityType.TypeName; this.dataGridView1.Rows[index].Cells[1].Value = commodityType.OderSart; this.dataGridView1.Rows[index].Tag = commodityType; } } }
private void save() { this.commdodityModel.CommodityName = this.tbName.Text; if (this.isReplaceImg) { this.commdodityModel.CommodityImg = this.newImageGUID + Path.GetExtension(this.tbImg.Text); } this.commdodityModel.CommodityGeneral = this.tbGeneral.Text; this.commdodityModel.CommodityPrice = double.Parse(this.tbPrice.Text); this.commdodityModel.UnitIdName = this.cmbUnit.SelectedText; this.commdodityModel.CommodityUnitId = (this.cmbUnit.SelectedItem as UnitModel).UnitIdId; this.commdodityModel.CommoditySpec = int.Parse(this.tbSpec.Text); this.commdodityModel.BrandName = this.cmbBrand.SelectedText; this.commdodityModel.CommodityBrandId = (this.cmbBrand.SelectedItem as BrandModel).BrandId; this.commdodityModel.CommodityFamilyId = (this.cmbCommodityType.SelectedItem as CommodityTypeModel).TypeId; this.commdodityModel.CommodityIndex = this.tbIndex.Text; this.commdodityModel.CommodityCode = this.tbCode.Text; this.commdodityModel.CommodityHOT = int.Parse(this.cmbHot.SelectedItem.ToString()); this.commdodityModel.CommodityRH = this.tbRH.Text; this.commdodityModel.CommodityRM = this.tbRM.Text; this.commdodityModel.CommodityFL = this.tbFL.Text; this.commdodityModel.CommodityRemark = this.rtbRemark.Text; if (this.maintainType == MaintainType.New) { this.commdodityModel.CommoditySuper = 1; var addResult = WebRequestUtil.AddCommodity(JsonUtil.Serialize(this.commdodityModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建商品失败"); } } else { var updateResult = WebRequestUtil.UpdateCommodity(this.commdodityModel.CommodityId, JsonUtil.Serialize(this.commdodityModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新商品失败"); } } //replace image if (this.isReplaceImg) { this.ReplaceImge(); } }
private void InitControls() { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns[0].Width = 100; this.dataGridView1.Columns[1].Width = 250; var result = WebRequestUtil.GetExLogisticList(); if (result != null) { var response = JsonUtil.Deserialize <QSWResponse <List <ExLogisticModel> > >(result.Content); List <ExLogisticModel> exModelList = response.Data; foreach (var ex in exModelList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = ex.ExId; this.dataGridView1.Rows[index].Cells[1].Value = ex.ExName; this.dataGridView1.Rows[index].Tag = ex; } } }
private void InitControls() { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns[0].Width = 100; this.dataGridView1.Columns[1].Width = 250; var result = WebRequestUtil.GetCityList(); if (result != null) { var response = JsonUtil.Deserialize <QSWResponse <List <CityModel> > >(result.Content); List <CityModel> cityModelList = response.Data; foreach (var city in cityModelList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = city.CityId; this.dataGridView1.Rows[index].Cells[1].Value = city.CityName; this.dataGridView1.Rows[index].Tag = city; } } }
private void btnDel_Click(object sender, EventArgs e) { if (this.kryptonDataGridView1.SelectedRows.Count > 0) { var adv = this.kryptonDataGridView1.SelectedRows[0].Tag as AdvModel; if (adv == null) { return; } var deleteResponse = WebRequestUtil.DeleteAdv(adv.AdvId); if (deleteResponse != null) { bool res = JsonUtil.Deserialize <QSWResponse <bool> >(deleteResponse.Content).Data; if (res) { this.kryptonDataGridView1.Rows.Remove(this.kryptonDataGridView1.SelectedRows[0]); WebRequestUtil.DeleteAdsImage(adv.AdvImage); } } } }
private void btnSave_Click(object sender, EventArgs e) { try { IHTMLDocument2 Doc2 = (IHTMLDocument2)webBrowser1.Document.DomDocument; try { Doc2.parentWindow.execScript("getTxtinfo();", "JavaScript"); } catch (Exception) { } var body = Doc2.body.outerHTML; //正则表达式获取DIV string str = string.Empty; if (!string.IsNullOrEmpty(body)) { MatchCollection mcDiv = Regex.Matches(body, "<SPAN id=cmtxt style=\"DISPLAY: none\">([\\s\\S]*?)</SPAN><SPAN id=spendtxt style=\"DISPLAY: none\">"); str = mcDiv[0].Groups[0].Value; str = str.Replace("<SPAN id=cmtxt style=\"DISPLAY: none\">", "").Replace("</SPAN><SPAN id=spendtxt style=\"DISPLAY: none\">", ""); } var re = WebRequestUtil.UpdateCommodityRemark(this.comId, str); if (re == null || re.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("保存失败!"); } else { MessageBox.Show("保存成功!"); this.Close(); } } catch (Exception ex) { LogUtil.Error("保存商品详情失败:" + ex.Message); MessageBox.Show("保存失败!"); } }
private void PreviewPic(string adsImageName) { var response = WebRequestUtil.GetAdsImage(adsImageName); if (response != null) { var data = JsonUtil.Deserialize <QSWResponse <string> >(response.Content); if (!string.IsNullOrEmpty(data.Data)) { var imgBytes = Convert.FromBase64String(data.Data); string imageFile = SaveToCache(imgBytes); this.pictureBox1.Image = new Bitmap(imageFile); } else { this.pictureBox1.Image = null; } } else { this.pictureBox1.Image = null; } }
private void Save() { this.brandModel.BrandName = this.tbName.Text; if (this.isReplaceImg) { this.brandModel.BrandImg = this.brandModel.BrandId + "1" + Path.GetExtension(this.tbImage.Text); } this.brandModel.BrandTypeId = 0; this.brandModel.BrandState = 0; int order = 0; int.TryParse(this.tbOrder.Text, out order); this.brandModel.OderSart = order; if (this.maintainType == MaintainType.New) { var addResult = WebRequestUtil.AddBrand(JsonUtil.Serialize(this.brandModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建品牌失败!"); } } else { var updateResult = WebRequestUtil.UpdateBrand(this.brandModel.BrandId, JsonUtil.Serialize(this.brandModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新品牌失败!"); } } //replace image if (this.isReplaceImg) { this.ReplaceImage(); } }
private void btnSaves_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.tbExName.Text)) { MessageBox.Show("请填写完整信息!"); return; } IRestResponse response; if (this.maintainType == MaintainType.New) { response = WebRequestUtil.AddExLogistic(this.tbExName.Text); } else { response = WebRequestUtil.UpdateExLogistic(this.exModel.ExId, this.tbExName.Text); } if (response == null || response.StatusCode != System.Net.HttpStatusCode.OK) { if (maintainType == MaintainType.New) { MessageBox.Show("新增快递信息失败!"); } else { MessageBox.Show("更新快递信息失败!"); } } else { this.DialogResult = DialogResult.OK; this.Close(); } }
private void InitControls() { this.dataGridView1.Rows.Clear(); this.dataGridView1.Columns[0].Width = 250; this.dataGridView1.Columns[1].Width = 150; this.dataGridView1.Columns[2].Width = 80; this.dataGridView1.Columns[3].Width = 80; this.dataGridView1.Columns[4].Width = 80; this.dataGridView1.Columns[5].Width = 80; this.dataGridView1.Columns[6].Width = 80; this.dataGridView1.Columns[7].Width = 80; this.dataGridView1.Columns[8].Width = 80; this.dataGridView1.Columns[9].Width = 80; var contentResult = WebRequestUtil.GetCommodityAllList(); if (contentResult != null) { var response = JsonUtil.Deserialize <QSWResponse <List <CommodityModel> > >(contentResult.Content); List <CommodityModel> commodityModelList = response.Data; foreach (var commodity in commodityModelList) { int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = commodity.CommodityName; this.dataGridView1.Rows[index].Cells[1].Value = commodity.CommodityGeneral; this.dataGridView1.Rows[index].Cells[2].Value = commodity.CommodityPrice; this.dataGridView1.Rows[index].Cells[3].Value = commodity.BrandName; this.dataGridView1.Rows[index].Cells[4].Value = commodity.CommodityCode; this.dataGridView1.Rows[index].Cells[5].Value = commodity.CommoditySpec; this.dataGridView1.Rows[index].Cells[6].Value = commodity.CommodityIndex; this.dataGridView1.Rows[index].Cells[7].Value = commodity.CommodityRH; this.dataGridView1.Rows[index].Cells[8].Value = commodity.CommodityFL; this.dataGridView1.Rows[index].Cells[9].Value = commodity.CommodityRM; this.dataGridView1.Rows[index].Tag = commodity; } } }
private void save() { this.commodityTypeModel.TypeName = this.tbCommodityTypeName.Text; int order = 0; int.TryParse(this.tbOrder.Text, out order); this.commodityTypeModel.OderSart = order; if (this.maintainType == MaintainType.New) { var addResult = WebRequestUtil.AddCommodityType(JsonUtil.Serialize(this.commodityTypeModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建商品类型失败"); } } else { var updateResult = WebRequestUtil.UpdateCommodityType(this.commodityTypeModel.TypeId, JsonUtil.Serialize(this.commodityTypeModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新商品类型失败"); } } }
private void save() { this.commdodityModel.CommodityName = this.tbName.Text; if (this.isReplaceImg) { this.commdodityModel.CommodityImg = this.commdodityModel.CommodityId + "1" + Path.GetExtension(this.tbImg.Text); //当前图片数量加1 } this.commdodityModel.CommodityGeneral = this.tbGeneral.Text; this.commdodityModel.CommodityPrice = double.Parse(this.tbPrice.Text); this.commdodityModel.UnitIdName = this.cmbUnit.SelectedText; this.commdodityModel.CommodityUnitId = (this.cmbUnit.SelectedItem as UnitModel).UnitIdId; this.commdodityModel.CommoditySpec = int.Parse(this.tbSpec.Text); this.commdodityModel.BrandName = this.cmbBrand.SelectedText; this.commdodityModel.CommodityBrandId = (this.cmbBrand.SelectedItem as BrandModel).BrandId; this.commdodityModel.CommodityFamilyId = (this.cmbCommodityType.SelectedItem as CommodityTypeModel).TypeId; this.commdodityModel.CommodityIndex = this.tbIndex.Text; this.commdodityModel.CommodityCode = this.tbCode.Text; // this.commdodityModel.CommodityHOT = int.Parse(this.cmbHot.SelectedItem.ToString()); this.commdodityModel.CommodityRH = this.tbRH.Text; //this.commdodityModel.CommodityRM = this.tbRM.Text; this.commdodityModel.CommodityFL = this.tbFL.Text; this.commdodityModel.CommodityRemark = string.Empty; switch (this.cmbHot.SelectedItem.ToString()) { case "正常": this.commdodityModel.CommoditySuper = 0; break; case "首页": this.commdodityModel.CommoditySuper = 1; break; } if (this.maintainType == MaintainType.New) { var addResult = WebRequestUtil.AddCommodity(JsonUtil.Serialize(this.commdodityModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建商品失败"); } else { var data = JsonUtil.Deserialize <QSWResponse <CommodityModel> >(addResult.Content).Data; this.commdodityModel.CommodityId = data.CommodityId; this.commdodityModel.CommodityImg = data.CommodityImg; } } else { var updateResult = WebRequestUtil.UpdateCommodity(this.commdodityModel.CommodityId, JsonUtil.Serialize(this.commdodityModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新商品失败"); } } //replace image if (this.isReplaceImg) { this.ReplaceImge(); } }