frmPackagesUpload.cs 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using LYFZ.Command;
  10. using LYFZ.ComponentLibrary;
  11. using System.Collections;
  12. using LYFZ.Software.MainBusiness.DoorCityProcess;
  13. using LYFZ.Software.MainBusiness.InitialSet;
  14. using LYFZ.Model;
  15. using System.Net;
  16. using System.IO;
  17. namespace LYFZ.Software.MainBusiness.MicroApplet
  18. {
  19. public partial class frmPackagesUpload : LYFZ.Software.MicroApplet.frmPackagesUpload
  20. {
  21. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  22. LYFZ.BLL.BLL_ErpProduct ptbll = new BLL.BLL_ErpProduct();
  23. LYFZ.BLL.BLL_ErpPackages pkbll = new BLL.BLL_ErpPackages();
  24. LYFZ.BLL.BLL_ErpTheScenery tsbll = new BLL.BLL_ErpTheScenery();
  25. LYFZ.BLL.BLL_ErpPackagesGiftMerchandise pgmbll = new BLL.BLL_ErpPackagesGiftMerchandise();
  26. public frmPackagesUpload(string StrType = "0")
  27. {
  28. if (!string.IsNullOrEmpty(StrType))
  29. {
  30. this.StrPackagesType = Convert.ToInt32(StrType);
  31. }
  32. else
  33. {
  34. this.StrPackagesType = 0;
  35. }
  36. this.Load += PackagesGoodsSetFormMain_Load;
  37. this.Shown += PackagesGoodsSetFormMain_Shown;
  38. this.cmbtreev_PackageName.ComboBoxTree_NodeMouseClick += cmbtreev_PackageName_ComboBoxTree_NodeMouseClick;
  39. this.btnSaveed.Click += btnSaveed_Click;
  40. this.btnCloseed.Click += btnCloseed_Click;
  41. this.TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
  42. this.btnPicSelect.Click += BtnPicSelect_Click;
  43. this.btnListImgSelect.Click += BtnListImgSelect_Click;
  44. this.btnSelectVideo_url.Click += BtnSelectVideo_url_Click;
  45. }
  46. /// <summary>
  47. /// 选择视频
  48. /// </summary>
  49. /// <param name="sender"></param>
  50. /// <param name="e"></param>
  51. private void BtnSelectVideo_url_Click(object sender, EventArgs e)
  52. {
  53. OpenFileDialog open = new OpenFileDialog();
  54. open.Multiselect = false;
  55. open.Title = "选择图片";
  56. open.Filter = "视频|*.mp4;*.flv;*.mov;*.wmv;*.avi;*.mpeg;*.mpeg;";
  57. if (open.ShowDialog() == DialogResult.OK)
  58. {
  59. this.txtVideo_url.Text = open.FileName;
  60. Video_url = open.FileName;
  61. }
  62. }
  63. MicroAppLoginReturn _appLoginModel = new MicroAppLoginReturn();
  64. public MicroAppLoginReturn AppLoginModel
  65. {
  66. get { return _appLoginModel; }
  67. set { _appLoginModel = value; }
  68. }
  69. /// <summary>
  70. /// 上传套系
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. void btnSaveed_Click(object sender, EventArgs e)
  75. {
  76. try
  77. {
  78. if (packModel != null && !string.IsNullOrEmpty(this.cmbtreev_PackageName.Text.Trim()))
  79. {
  80. LYFZ.Command.Result<dynamic> res = (LYFZ.Command.Result<dynamic>)pkbll.GetSelectTaoXiLeiXing(packModel);
  81. MicroAppReturn returnData = new MicroAppReturn();
  82. if (!this.rdoErTong.Checked && !this.rdoHungSha.Checked && !this.rdoPuTong.Checked)
  83. {
  84. MessageBoxCustom.Show("请选择套系类型");
  85. return;
  86. }
  87. //小程序套系分类
  88. int categoty_id = -1;
  89. try
  90. {
  91. if (this.cbxFengLie.SelectedItem == null)
  92. {
  93. MessageBoxCustom.Show("请选择套系分类");
  94. return;
  95. }
  96. else
  97. {
  98. ItemValue item = (ItemValue)this.cbxFengLie.SelectedItem;
  99. categoty_id = Convert.ToInt32(item.Value);
  100. }
  101. }
  102. catch (Exception ex)
  103. {
  104. MessageBoxCustom.Show("选择套系分类时出错:{0}", ex.Message);
  105. return;
  106. }
  107. this.picImagePath = this.txtPicImage.Text.Trim();
  108. List<string> UpdoadImageList = new List<string>();
  109. if (this.listImageList.Items.Count > 0)
  110. {
  111. foreach (string path in this.listImageList.Items)
  112. {
  113. UpdoadImageList.Add(path);
  114. }
  115. }
  116. //服务装套数
  117. int clothCount = 1;
  118. //景点
  119. string sceneName = "";
  120. //入底
  121. int negativeCount = 0;
  122. //入册
  123. int meticulouslyCount = 0;
  124. if (this.rdoErTong.Checked)
  125. {
  126. clothCount = ErTongFuZhuangShu;
  127. sceneName = String.Join(", ", this.ErTongJingDianList.ToArray());
  128. negativeCount = ErTongRuDiShu;
  129. meticulouslyCount = ErTongRuCheShu;
  130. }
  131. else
  132. {
  133. clothCount = PuTongFuZhuangShu;
  134. sceneName = String.Join(", ", this.PuTongJingDianList.ToArray());
  135. negativeCount = PuTongRuDiShu;
  136. meticulouslyCount = PuTongRuCheShu;
  137. }
  138. dynamic TaoXiData = new
  139. {
  140. TaoXiBianMa = this.packModel.Pak_PackagesID,
  141. TaoXiMingCheng = this.packModel.Pak_Name,
  142. TaoXiJiaGe = this.packModel.Pak_UnitPrice,
  143. TaoXiLeiYongData = res.Data,
  144. };
  145. if (String.IsNullOrEmpty(sceneName))
  146. {
  147. MessageBoxCustom.Show("当前套系未设置对应的景点或拍摄阶段");
  148. return;
  149. }
  150. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  151. {
  152. try
  153. {
  154. string uploadVideo_url = "";
  155. if (this.Video_url.Trim().Length > 0)
  156. {
  157. backgroundWorker.ReportProgress(0, "正在上传视频...");
  158. MicroAppReturn returnUploadPicData = UploadPhoto(this.Video_url.Trim());
  159. if (returnUploadPicData.Code == 200)
  160. {
  161. dynamic PicData = Newtonsoft.Json.JsonConvert.DeserializeObject(returnUploadPicData.Data);
  162. uploadVideo_url = PicData["img_route"];
  163. }
  164. else
  165. {
  166. returnData.Message = String.Format("视频上传失败:{0}", returnUploadPicData.Message);
  167. return;
  168. }
  169. }
  170. backgroundWorker.ReportProgress(0, "正在上传图片...");
  171. string picImageUrl = "";
  172. if (this.picImagePath.Trim().Length > 0)
  173. {
  174. MicroAppReturn returnUploadPicData = UploadPhoto(this.picImagePath.Trim());
  175. if (returnUploadPicData.Code == 200)
  176. {
  177. dynamic PicData = Newtonsoft.Json.JsonConvert.DeserializeObject(returnUploadPicData.Data);
  178. picImageUrl = PicData["img_route"];
  179. }
  180. else
  181. {
  182. returnData.Message = returnUploadPicData.Message; return;
  183. }
  184. }
  185. else
  186. {
  187. returnData.Message = "请选择标题图片"; return;
  188. }
  189. List<string> imageUrlList = new List<string>();
  190. if (UpdoadImageList.Count > 0)
  191. {
  192. foreach (string path in UpdoadImageList)
  193. {
  194. MicroAppReturn tUploadPicData = UploadPhoto(path.Trim());
  195. if (tUploadPicData.Code == 200)
  196. {
  197. dynamic tPicData = Newtonsoft.Json.JsonConvert.DeserializeObject(tUploadPicData.Data);
  198. string tempImageUrl = tPicData["img_route"];
  199. imageUrlList.Add(tempImageUrl);
  200. }
  201. else
  202. {
  203. returnData.Message = tUploadPicData.Message; return;
  204. }
  205. }
  206. }
  207. else
  208. {
  209. returnData.Message = "请选择展示图片"; return;
  210. }
  211. backgroundWorker.ReportProgress(0, "正在上传套系数据...");
  212. string tempstr = Newtonsoft.Json.JsonConvert.SerializeObject(TaoXiData);
  213. dynamic extraData = new
  214. {
  215. clothCount = clothCount.ToString(),
  216. sceneName = sceneName,
  217. duration = this.txtFuWuShiChang.Text.Trim(),
  218. negativeCount = negativeCount,
  219. meticulouslyCount = meticulouslyCount,
  220. orderDetail = this.ShangPingList.ToArray(),
  221. agreement = txtXieYi.lines,
  222. sceneIntro = this.HuFuList.ToArray(),
  223. purchaseNotes = txtGouMaiXuZhi.Text.Trim(),
  224. pictureUrl = imageUrlList.ToArray(),
  225. imgUrl = picImageUrl
  226. };
  227. int series_type = this.rdoErTong.Checked ? 2 : this.rdoHungSha.Checked ? 1 : 3;
  228. dynamic PackageData = new
  229. {
  230. title = this.packModel.Pak_Name,
  231. categoty_id = categoty_id,
  232. price = this.nuDingJing.Value,
  233. price_original = this.packModel.Pak_UnitPrice,
  234. series_type = series_type,
  235. cover_url = picImageUrl,
  236. video_url = uploadVideo_url,
  237. series_id = "",
  238. extra = extraData,
  239. extra_id = String.Format("{0}{1}", this.packModel.Pak_PackagesID, series_type),
  240. third_party_data = TaoXiData
  241. };
  242. string postData = Newtonsoft.Json.JsonConvert.SerializeObject(PackageData);
  243. string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(frmSynchronousData.addSeriesData, postData, _appLoginModel, Encoding.UTF8);
  244. if (PostReturnString.IndexOf("{") == 0)
  245. {
  246. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  247. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  248. {
  249. returnData.Code = 200;
  250. returnData.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  251. }
  252. else
  253. {
  254. returnData.Message = postReturnObj["meta"]["message"];
  255. }
  256. }
  257. else
  258. {
  259. returnData.Message = PostReturnString;
  260. }
  261. }
  262. catch (Exception ex)
  263. {
  264. MessageBoxCustom.Show(String.Format("上传套系数据时错误:{0}", ex.Message));
  265. }
  266. });
  267. if (returnData.Code == 200)
  268. {
  269. MessageBoxCustom.Show(String.Format("上传套系数据已上传成功"));
  270. }
  271. else
  272. {
  273. MessageBoxCustom.Show(String.Format("上传套系数据时失败:{0}", returnData.Message));
  274. }
  275. }
  276. else
  277. {
  278. MessageBoxCustom.Show("请选择套系");
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. MessageBoxCustom.Show(String.Format("上传套系数据时出错误:{0}", ex.Message));
  284. }
  285. }
  286. MicroAppReturn UploadPhoto(string photoPath)
  287. {
  288. MicroAppReturn data = new MicroAppReturn();
  289. string PostReturnString = SendHttpRequestPost(frmSynchronousData.uploadImg, photoPath, _appLoginModel, Encoding.UTF8);
  290. if (PostReturnString.IndexOf("{") == 0)
  291. {
  292. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  293. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  294. {
  295. data.Code = 200;
  296. data.Data = Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  297. }
  298. else
  299. {
  300. data.Message = postReturnObj["meta"]["message"];
  301. }
  302. }
  303. else
  304. {
  305. data.Message = PostReturnString;
  306. }
  307. return data;
  308. }
  309. /// <summary>
  310. /// 向指定的URL地址发起一个POST请求,同时可以上传一些数据项以及上传文件。
  311. /// </summary>
  312. /// <param name="url">要请求的URL地址</param>
  313. /// <param name="fileList">要上传的文件列表</param>
  314. /// <param name="encoding">发送数据项,接收的字符编码方式</param>
  315. /// <returns>服务器的返回结果</returns>
  316. public string SendHttpRequestPost(string url, string filePath, MicroAppLoginReturn appLogin, Encoding encoding=null)
  317. {
  318. if (string.IsNullOrEmpty(url))
  319. throw new ArgumentNullException("url");
  320. if (encoding == null)
  321. encoding = Encoding.UTF8;
  322. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  323. request.Method = "POST"; // 要上传文件,一定要是POST方法
  324. request.Headers.Add("token", appLogin.AppToken);
  325. request.Headers.Add("bindcode", appLogin.Bind_code);
  326. // 数据块的分隔标记,用于设置请求头,注意:这个地方最好不要使用汉字。
  327. string boundary = "---------------------------" + Guid.NewGuid().ToString("N");
  328. // 数据块的分隔标记,用于写入请求体。
  329. // 注意:前面多了一段: "--" ,而且它们将独占一行。
  330. byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
  331. // 设置请求头。指示是一个上传表单,以及各数据块的分隔标记。
  332. request.ContentType = "multipart/form-data; boundary=" + boundary;
  333. // 先得到请求流,准备写入数据。
  334. Stream stream = request.GetRequestStream();
  335. // 写入要上传的文件
  336. // foreach (DictionaryEntry kvp in fileList)//KeyValuePair<string, string> kvp
  337. {
  338. // 写入数据块的分隔标记
  339. stream.Write(boundaryBytes, 0, boundaryBytes.Length);
  340. string photoFile = filePath;// kvp.Value.ToString();
  341. /* if (".jpg,.png.jpge".Contains(System.IO.Path.GetExtension(photoFile).ToLower().Trim()))
  342. {
  343. Bitmap bmp = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(photoFile, 640, 960);
  344. photoFile = LYFZ.ImageFunction.ThumbImgae.SaveTemporaryCompressionImage(bmp, System.IO.Path.GetFileName(photoFile));
  345. }*/
  346. // 写入文件描述,这里设置一个通用的类型描述:application/octet-stream,具体的描述在注册表里有。
  347. string description = string.Format(
  348. "Content-Disposition: form-data; name=\"file\"; filename=\"{0}\"\r\n" +
  349. "Content-Type: application/octet-stream\r\n\r\n",
  350. Path.GetFileName(photoFile.Trim()));
  351. // 注意:这里如果不使用UTF-8,对于汉字会有乱码。
  352. byte[] header = Encoding.UTF8.GetBytes(description);
  353. stream.Write(header, 0, header.Length);
  354. // 写入文件内容
  355. byte[] body = File.ReadAllBytes(photoFile.Trim());
  356. stream.Write(body, 0, body.Length);
  357. /* if (".jpg,.png.jpge".Contains(System.IO.Path.GetExtension(photoFile).ToLower().Trim()))
  358. {
  359. LYFZ.ImageFunction.ThumbImgae.DeleteTemporaryCompressionImage(photoFile);
  360. }*/
  361. }
  362. // 写入结束标记
  363. boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
  364. stream.Write(boundaryBytes, 0, boundaryBytes.Length);
  365. stream.Close();
  366. try
  367. {
  368. // 开始发起请求,并获取服务器返回的结果。
  369. using (WebResponse response = request.GetResponse())
  370. {
  371. request.Timeout = 300000;
  372. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  373. {
  374. return reader.ReadToEnd();
  375. }
  376. }
  377. }
  378. catch (Exception ex){ return ex.Message; }
  379. }
  380. string Video_url = "";
  381. string picImagePath = "";
  382. List<string> appImageList = new List<string>();
  383. private void BtnListImgSelect_Click(object sender, EventArgs e)
  384. {
  385. OpenFileDialog open = new OpenFileDialog();
  386. open.Title = "选择图片";
  387. open.Multiselect = true;
  388. open.Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;";
  389. if (open.ShowDialog() == DialogResult.OK)
  390. {
  391. appImageList.Clear();
  392. this.listImageList.Items.Clear();
  393. this.listImageList.Items.AddRange(open.FileNames);
  394. appImageList.AddRange(open.FileNames);
  395. }
  396. }
  397. private void BtnPicSelect_Click(object sender, EventArgs e)
  398. {
  399. OpenFileDialog open = new OpenFileDialog();
  400. open.Multiselect = false;
  401. open.Title = "选择图片";
  402. open.Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;";
  403. if (open.ShowDialog() == DialogResult.OK)
  404. {
  405. this.txtPicImage.Text = open.FileName;
  406. picImagePath = open.FileName;
  407. }
  408. }
  409. /// <summary>
  410. /// 套系大类类型
  411. /// </summary>
  412. public int StrPackagesType;
  413. /// <summary>
  414. /// 是否保存
  415. /// </summary>
  416. public bool IsSaveed = false;
  417. /// <summary>
  418. /// 存储产品略图集合
  419. /// </summary>
  420. ImageList mlistImage = new ImageList();
  421. /// <summary>
  422. /// true为首次运行
  423. /// </summary>
  424. private bool IsFirstLoad = true;
  425. /// <summary>
  426. /// 窗体加载事件
  427. /// </summary>
  428. /// <param name="sender"></param>
  429. /// <param name="e"></param>
  430. void PackagesGoodsSetFormMain_Load(object sender, EventArgs e)
  431. {
  432. this.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  433. this.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  434. switch (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
  435. {
  436. case EnumPermissions.BusinessType.儿童版:
  437. this.rdoErTong.Checked = true;
  438. this.rdoHungSha.Hide();
  439. break;
  440. case EnumPermissions.BusinessType.婚纱版:
  441. this.rdoHungSha.Checked = true;
  442. this.rdoErTong.Hide();
  443. break;
  444. }
  445. if (this.StrPackagesType == 1)
  446. {
  447. // this.panelEx4.Visible = false;
  448. this.Text = "礼包套系商品设置";
  449. this.labelEx6.Text = "套系礼包商品";
  450. this.labelEx8.Text = "套系礼包服务";
  451. }
  452. else
  453. {
  454. this.txtIntoBottom.WaterText = "-1表示全送";
  455. }
  456. }
  457. /// <summary>
  458. /// 窗体加载事件
  459. /// </summary>
  460. /// <param name="sender"></param>
  461. /// <param name="e"></param>
  462. void PackagesGoodsSetFormMain_Shown(object sender, EventArgs e)
  463. {
  464. dynamic returnData = null;
  465. string errorMsg = "";
  466. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate (object obj, BackgroundWorker backgroundWorker)
  467. {
  468. try
  469. {
  470. string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new { page = 1 });
  471. string PostReturnString = frmMicroAppletAdmin.HttpWebRequestPOST(frmSynchronousData.categotyData, postData, _appLoginModel, Encoding.UTF8);
  472. if (PostReturnString.IndexOf("{") == 0)
  473. {
  474. dynamic postReturnObj = Newtonsoft.Json.JsonConvert.DeserializeObject(PostReturnString);
  475. if (Convert.ToInt32(postReturnObj["meta"]["code"]) == 200)
  476. {
  477. returnData = postReturnObj["body"]["data_list"];// Newtonsoft.Json.JsonConvert.SerializeObject(postReturnObj["body"]);
  478. }
  479. else
  480. {
  481. errorMsg = postReturnObj["meta"]["message"];
  482. }
  483. }
  484. else
  485. {
  486. errorMsg = PostReturnString;
  487. }
  488. }
  489. catch (Exception ex)
  490. {
  491. errorMsg = ex.Message;
  492. }
  493. });
  494. if (returnData != null)
  495. {
  496. try
  497. {
  498. foreach (dynamic itemObj in returnData)
  499. {
  500. ItemValue item = new ItemValue(Convert.ToInt32(itemObj.id), itemObj.name.ToString());
  501. this.cbxFengLie.Items.Add(item);
  502. }
  503. }
  504. catch (Exception ex)
  505. {
  506. MessageBoxCustom.Show(String.Format("绑定小程序套系分类时出错:{0}",ex.Message));
  507. }
  508. }
  509. else {
  510. MessageBoxCustom.Show(String.Format("获取小程序套系分类失败:{0}",errorMsg));
  511. }
  512. //获取绑定拍摄次数 获取绑定套系名称
  513. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PackagesCategoryAndName(this.cmbtreev_PackageName, StrParentCode: Enum.GetName(typeof(LYFZ.EnumPublic.EnumPackagesType), StrPackagesType).ToString().Trim());
  514. this.tabPage1.Parent = null;
  515. this.tabPage2.Parent = null;
  516. switch (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
  517. {
  518. case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.儿童版:
  519. if (!LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsEnablePhotoEdition)
  520. {
  521. this.tabPage2.Parent = this.TabControl;
  522. }
  523. else
  524. {
  525. this.tabPage1.Parent = this.TabControl;
  526. this.tabPage2.Parent = this.TabControl;
  527. }
  528. break;
  529. case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.婚纱版:
  530. this.tabPage1.Parent = this.TabControl;
  531. break;
  532. default:
  533. this.tabPage1.Parent = this.TabControl;
  534. this.tabPage2.Parent = this.TabControl;
  535. break;
  536. }
  537. #region 设置列表标题
  538. #region 商品表标题
  539. this.listViewData_Product.View = View.Details;
  540. this.listViewData_Product.GridLines = true;
  541. string[] StrColumns = "商品名称,数量,进货价格,销售单价".Split(',');
  542. int SurplusCount = 90 + 85 + 85 + 23;
  543. for (int i = 0; i < StrColumns.Length; i++)
  544. {
  545. ColumnHeader ch = new ColumnHeader();
  546. ch.Text = StrColumns[i].Trim();
  547. ch.TextAlign = HorizontalAlignment.Left;
  548. if (i == 0)
  549. { ch.Width = this.listViewData_Product.Width - SurplusCount; }
  550. else if (i == StrColumns.Length - 1)
  551. { ch.Width = 90; }
  552. else
  553. { ch.Width = 85; }
  554. switch (StrColumns[i].Trim())
  555. {
  556. case "进货价格":
  557. case "销售单价":
  558. ch.TextAlign = HorizontalAlignment.Right;
  559. break;
  560. default:
  561. ch.TextAlign = HorizontalAlignment.Center;
  562. break;
  563. }
  564. this.listViewData_Product.Columns.Add(ch);
  565. }
  566. this.mlistImage.ImageSize = new Size(25, 25);
  567. this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
  568. this.listViewData_Product.SmallImageList = mlistImage;
  569. this.listViewData_Product.MultiSelect = true;
  570. #endregion
  571. #region 服务表标题
  572. this.listViewData_Service.View = View.Details;
  573. this.listViewData_Service.GridLines = true;
  574. for (int i = 0; i < StrColumns.Length; i++)
  575. {
  576. ColumnHeader ch = new ColumnHeader();
  577. ch.Text = StrColumns[i].Trim();
  578. ch.TextAlign = HorizontalAlignment.Left;
  579. if (i == 0)
  580. {
  581. ch.Width = this.listViewData_Service.Width - SurplusCount;
  582. }
  583. else if (i == StrColumns.Length - 1)
  584. {
  585. ch.Width = 90;
  586. }
  587. else
  588. {
  589. ch.Width = 85;
  590. }
  591. switch (StrColumns[i].Trim())
  592. {
  593. case "进货价格":
  594. case "销售单价":
  595. ch.TextAlign = HorizontalAlignment.Right;
  596. break;
  597. default:
  598. ch.TextAlign = HorizontalAlignment.Center;
  599. break;
  600. }
  601. this.listViewData_Service.Columns.Add(ch);
  602. }
  603. this.listViewData_Service.SmallImageList = mlistImage;
  604. this.listViewData_Service.MultiSelect = true;
  605. #endregion
  606. #region 景点表标题
  607. this.listViewData_Sights.View = View.Details;
  608. this.listViewData_Sights.GridLines = true;
  609. ImageList imgList = new ImageList();
  610. imgList.ImageSize = new Size(1, 25);
  611. this.listViewData_Sights.SmallImageList = imgList;
  612. StrColumns = "景点名称,服装套数,成本单价,销售单价".Split(',');
  613. SurplusCount = 90 + 85 + 85 + 23;
  614. for (int i = 0; i < StrColumns.Length; i++)
  615. {
  616. ColumnHeader ch = new ColumnHeader();
  617. ch.Text = StrColumns[i].Trim();
  618. ch.TextAlign = HorizontalAlignment.Left;
  619. if (i == 0)
  620. {
  621. ch.Width = this.listViewData_Sights.Width - SurplusCount;
  622. }
  623. else if (i == StrColumns.Length - 1)
  624. {
  625. ch.Width = 90;
  626. }
  627. else
  628. {
  629. ch.Width = 85;
  630. }
  631. switch (StrColumns[i].Trim())
  632. {
  633. case "成本单价":
  634. case "销售单价":
  635. ch.TextAlign = HorizontalAlignment.Right;
  636. break;
  637. default:
  638. ch.TextAlign = HorizontalAlignment.Center;
  639. break;
  640. }
  641. this.listViewData_Sights.Columns.Add(ch);
  642. }
  643. #endregion
  644. #region 拍摄次数表标题
  645. this.listViewData_Stages.View = View.Details;
  646. this.listViewData_Stages.GridLines = true;
  647. this.listViewData_Stages.SmallImageList = imgList;
  648. StrColumns = "次数名称,入册,入底,服装套数".Split(',');
  649. for (int i = 0; i < StrColumns.Length; i++)
  650. {
  651. ColumnHeader ch = new ColumnHeader();
  652. ch.Text = StrColumns[i].Trim();
  653. switch (StrColumns[i].Trim())
  654. {
  655. case "次数名称": ch.Width = this.listViewData_Stages.Width - 270 - 23; break;
  656. case "入册": ch.Width = 90; break;
  657. case "入底": ch.Width = 90; break;
  658. case "服装套数": ch.Width = 90; break;
  659. }
  660. switch (StrColumns[i].Trim())
  661. {
  662. case "次数名称": ch.TextAlign = HorizontalAlignment.Left; break;
  663. case "入册":
  664. case "入底":
  665. case "服装套数": ch.TextAlign = HorizontalAlignment.Center; break;
  666. }
  667. this.listViewData_Stages.Columns.Add(ch);
  668. }
  669. #endregion
  670. #endregion
  671. this.IsFirstLoad = false;
  672. }
  673. LYFZ.Model.Model_ErpPackages packModel = null;
  674. //普通单
  675. List<string> PuTongJingDianList = new List<string>();
  676. int PuTongRuDiShu = 0;
  677. int PuTongRuCheShu = 0;
  678. int PuTongFuZhuangShu = 0;
  679. //儿童单
  680. List<string> ErTongJingDianList = new List<string>();
  681. int ErTongRuDiShu = 0;
  682. int ErTongRuCheShu = 0;
  683. int ErTongFuZhuangShu = 0;
  684. List<string> ShangPingList = new List<string>();
  685. List<string> HuFuList = new List<string>();
  686. /// <summary>
  687. /// 套系名称选择设置
  688. /// </summary>
  689. /// <param name="sender"></param>
  690. /// <param name="e"></param>
  691. void cmbtreev_PackageName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  692. {
  693. this.listViewData_Product.Items.Clear();
  694. this.listViewData_Product.Groups.Clear();
  695. this.listViewData_Service.Items.Clear();
  696. this.listViewData_Service.Groups.Clear();
  697. this.listViewData_Sights.Items.Clear();
  698. this.listViewData_Stages.Items.Clear();
  699. this.PuTongJingDianList.Clear();
  700. this.ErTongJingDianList.Clear();
  701. this.ShangPingList.Clear();
  702. this.HuFuList.Clear();
  703. PuTongRuDiShu = 0;
  704. PuTongRuCheShu = 0;
  705. PuTongFuZhuangShu = 0;
  706. ErTongRuDiShu = 0;
  707. ErTongRuCheShu = 0;
  708. ErTongFuZhuangShu = 0;
  709. packModel = null;
  710. // this.IsDataChange = false;
  711. //获取套系名称资料
  712. packModel = pkbll.GetModel("Pak_PackagesID", this.cmbtreev_PackageName.Tag.ToString().Trim());
  713. // DataTable dt = orbll.GetView_Custom("tb_ErpPackages", StrWhere: "Pak_PackagesID='" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "'", ShowColumnName: "Pak_UnitPrice,Pak_IntoTheArchive,Pak_IntoTheBook").Tables[0];
  714. if (packModel.ID > 0)
  715. {
  716. this.lblPakUnitPrice.Text = "套系价格:" + packModel.Pak_UnitPrice.ToString();// dt.Rows[0]["Pak_UnitPrice"].ToString().Trim();
  717. this.txtIntoRegister.Text = packModel.Pak_IntoTheBook.ToString();// dt.Rows[0]["Pak_IntoTheBook"].ToString().Trim();
  718. this.txtIntoBottom.Text = packModel.Pak_IntoTheArchive.ToString();// dt.Rows[0]["Pak_IntoTheArchive"].ToString().Trim();
  719. this.PuTongRuDiShu = packModel.Pak_IntoTheArchive;
  720. this.PuTongRuCheShu = packModel.Pak_IntoTheBook;
  721. #region 景点与次数
  722. DataTable tblSights = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise Left Join tb_ErpTheScenery on tb_ErpTheScenery.ID = Pgm_ProductNumber", StrWhere: "Tsc_Name is not null And Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in (2,3)", ShowColumnName: "tb_ErpPackagesGiftMerchandise.ID,Pgm_GiveType,Pgm_PackagesCode,Pgm_ProductNumber,Pgm_Quantity,Tsc_Name,Tsc_CostPrice,Tsc_SalesPrice,Pgm_IntoRegisterQuantity,Pgm_IntoBottomQuantity").Tables[0];
  723. for (int i = 0; i < tblSights.Rows.Count; i++)
  724. {
  725. ListViewItem lvItem = new ListViewItem();
  726. lvItem.Tag = tblSights.Rows[i]["Pgm_ProductNumber"].ToString().Trim() + "|" + tblSights.Rows[i]["ID"].ToString().Trim();
  727. lvItem.Text = tblSights.Rows[i]["Tsc_Name"].ToString().Trim();
  728. if (tblSights.Rows[i]["Pgm_GiveType"].ToString().Trim() == "2")
  729. {
  730. this.PuTongJingDianList.Add(lvItem.Text);
  731. try
  732. {
  733. this.PuTongFuZhuangShu += Convert.ToInt32(tblSights.Rows[i]["Pgm_Quantity"].ToString());
  734. }
  735. catch { }
  736. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  737. ListSubItem.Name = "服装套数";
  738. ListSubItem.Text = tblSights.Rows[i]["Pgm_Quantity"].ToString().Trim();
  739. lvItem.SubItems.Add(ListSubItem);
  740. ListSubItem = new ListViewItem.ListViewSubItem();
  741. ListSubItem.Name = "成本单价";
  742. ListSubItem.Text = tblSights.Rows[i]["Tsc_CostPrice"].ToString().Trim();
  743. lvItem.SubItems.Add(ListSubItem);
  744. ListSubItem = new ListViewItem.ListViewSubItem();
  745. ListSubItem.Name = "销售单价";
  746. ListSubItem.Text = tblSights.Rows[i]["Tsc_SalesPrice"].ToString().Trim();
  747. lvItem.SubItems.Add(ListSubItem);
  748. if ((this.listViewData_Sights.Items.Count % 2) > 0)
  749. { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
  750. else
  751. { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
  752. this.listViewData_Sights.Items.Add(lvItem);
  753. }
  754. else if (tblSights.Rows[i]["Pgm_GiveType"].ToString().Trim() == "3")
  755. {
  756. this.ErTongJingDianList.Add(lvItem.Text);
  757. try
  758. {
  759. this.ErTongFuZhuangShu += Convert.ToInt32(tblSights.Rows[i]["Pgm_Quantity"].ToString());
  760. this.ErTongRuDiShu += Convert.ToInt32(tblSights.Rows[i]["Pgm_IntoBottomQuantity"].ToString());
  761. this.ErTongRuCheShu += Convert.ToInt32(tblSights.Rows[i]["Pgm_IntoRegisterQuantity"].ToString());
  762. }
  763. catch { }
  764. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  765. ListSubItem.Name = "入册";
  766. ListSubItem.Text = tblSights.Rows[i]["Pgm_IntoRegisterQuantity"].ToString().Trim();
  767. lvItem.SubItems.Add(ListSubItem);
  768. ListSubItem = new ListViewItem.ListViewSubItem();
  769. ListSubItem.Name = "入底";
  770. ListSubItem.Text = tblSights.Rows[i]["Pgm_IntoBottomQuantity"].ToString().Trim();
  771. lvItem.SubItems.Add(ListSubItem);
  772. ListSubItem = new ListViewItem.ListViewSubItem();
  773. ListSubItem.Name = "服装套数";
  774. ListSubItem.Text = tblSights.Rows[i]["Pgm_Quantity"].ToString().Trim();
  775. lvItem.SubItems.Add(ListSubItem);
  776. if ((this.listViewData_Stages.Items.Count % 2) > 0)
  777. { lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
  778. else
  779. { lvItem.BackColor = System.Drawing.Color.PowderBlue; }
  780. ListViewGroup man_lvg = new ListViewGroup();
  781. man_lvg.Tag = lvItem.Text;
  782. man_lvg.Name = lvItem.Text;
  783. man_lvg.Header = lvItem.Text;
  784. man_lvg.HeaderAlignment = HorizontalAlignment.Left;
  785. this.listViewData_Product.Groups.Add(man_lvg);
  786. man_lvg = new ListViewGroup();
  787. man_lvg.Tag = lvItem.Text;
  788. man_lvg.Name = lvItem.Text;
  789. man_lvg.Header = lvItem.Text;
  790. man_lvg.HeaderAlignment = HorizontalAlignment.Left;
  791. this.listViewData_Service.Groups.Add(man_lvg);
  792. this.listViewData_Stages.Items.Add(lvItem);
  793. }
  794. }
  795. #endregion
  796. #region 商品与服务
  797. if (this.tabPage2.Parent == null)
  798. {
  799. string StrTableName = "(select Prod_Class,Sc_ClassName,Pgm_GiveType,Pgm_PackagesCode from tb_ErpPackagesGiftMerchandise Left Join tb_ErpProduct on Prod_Number = Pgm_ProductNumber " +
  800. "Left Join tb_ErpSystemCategory on Prod_Class = Sc_ClassCode Group by Prod_Class,Sc_ClassName,Pgm_GiveType,Pgm_PackagesCode ) as tb";
  801. DataTable dtGroup = orbll.GetView_Custom(StrTableName, StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in ('0','1')", ShowColumnName: "*").Tables[0];
  802. ListViewGroup man_lvg = null;
  803. for (int i = 0; i < dtGroup.Rows.Count; i++)
  804. {
  805. man_lvg = new ListViewGroup();
  806. man_lvg.Tag = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
  807. man_lvg.Name = dtGroup.Rows[i]["Prod_Class"].ToString().Trim();
  808. man_lvg.Header = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
  809. man_lvg.HeaderAlignment = HorizontalAlignment.Left;
  810. if (dtGroup.Rows[i]["Pgm_GiveType"].ToString().Trim() == "0")
  811. { this.listViewData_Product.Groups.Add(man_lvg); }
  812. else if (dtGroup.Rows[i]["Pgm_GiveType"].ToString().Trim() == "1")
  813. { this.listViewData_Service.Groups.Add(man_lvg); }
  814. }
  815. }
  816. else
  817. {
  818. ListViewGroup man_lvg = new ListViewGroup();
  819. man_lvg.Tag = "";
  820. man_lvg.Name = "NotGroup";
  821. man_lvg.Header = "未分组";
  822. man_lvg.HeaderAlignment = HorizontalAlignment.Left;
  823. this.listViewData_Product.Groups.Add(man_lvg);
  824. man_lvg = new ListViewGroup();
  825. man_lvg.Tag = "";
  826. man_lvg.Name = "NotGroup";
  827. man_lvg.Header = "未分组";
  828. man_lvg.HeaderAlignment = HorizontalAlignment.Left;
  829. this.listViewData_Service.Groups.Add(man_lvg);
  830. }
  831. DataTable tblProduct = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise Left Join tb_ErpProduct on Prod_Number = Pgm_ProductNumber", StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in ('0','1')", ShowColumnName: "tb_ErpPackagesGiftMerchandise.ID,Pgm_GiveType,Pgm_PackagesCode,Pgm_Quantity,Prod_Number,Prod_Name,Prod_Unit,Prod_CostPrice,Prod_SalesPrice,Prod_Thumbnail,Prod_Class,Pgm_ProductGroupName").Tables[0];
  832. for (int i = 0; i < tblProduct.Rows.Count; i++)
  833. {
  834. if (!this.mlistImage.Images.Keys.Contains(tblProduct.Rows[i]["Prod_Number"].ToString().Trim()))
  835. {
  836. Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(tblProduct.Rows[i]["Prod_Thumbnail"].ToString().Trim());
  837. this.mlistImage.Images.Add(tblProduct.Rows[i]["Prod_Number"].ToString().Trim(), img);
  838. }
  839. ListViewItem lvItem = new ListViewItem();
  840. lvItem.Tag = tblProduct.Rows[i]["Prod_Number"].ToString().Trim() + "|" + tblProduct.Rows[i]["ID"].ToString().Trim();
  841. lvItem.ImageKey = tblProduct.Rows[i]["Prod_Number"].ToString().Trim();
  842. lvItem.Text = tblProduct.Rows[i]["Prod_Name"].ToString().Trim();
  843. if (tblProduct.Rows[i]["Prod_Number"] == null || string.IsNullOrEmpty(tblProduct.Rows[i]["Prod_Number"].ToString()))
  844. {
  845. lvItem.Text = "此产品已在产品设置表中删除";
  846. lvItem.ForeColor = Color.Red;
  847. }
  848. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  849. ListSubItem.Name = "数量";
  850. ListSubItem.Text = tblProduct.Rows[i]["Pgm_Quantity"].ToString().Trim();
  851. lvItem.SubItems.Add(ListSubItem);
  852. ListSubItem = new ListViewItem.ListViewSubItem();
  853. ListSubItem.Name = "进货价格";
  854. ListSubItem.Text = tblProduct.Rows[i]["Prod_CostPrice"].ToString().Trim();
  855. lvItem.SubItems.Add(ListSubItem);
  856. ListSubItem = new ListViewItem.ListViewSubItem();
  857. ListSubItem.Name = "销售单价";
  858. ListSubItem.Text = tblProduct.Rows[i]["Prod_SalesPrice"].ToString().Trim();
  859. lvItem.SubItems.Add(ListSubItem);
  860. if (tblProduct.Rows[i]["Pgm_GiveType"].ToString().Trim() == "0")
  861. {
  862. this.ShangPingList.Add(String.Format("{0} {1} {2}",lvItem.Text, tblProduct.Rows[i]["Pgm_Quantity"].ToString().Trim(), tblProduct.Rows[i]["Prod_Unit"].ToString().Trim()));
  863. if (this.tabPage2.Parent == null)
  864. {
  865. if (this.listViewData_Product.Groups.Count > 0)
  866. { this.listViewData_Product.Groups[tblProduct.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
  867. }
  868. else
  869. {
  870. if (!string.IsNullOrEmpty(tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()))
  871. {
  872. if (this.listViewData_Product.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()] != null)
  873. {
  874. this.listViewData_Product.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()].Items.Add(lvItem);
  875. }
  876. else
  877. {
  878. this.listViewData_Product.Groups["NotGroup"].Items.Add(lvItem);
  879. }
  880. }
  881. else
  882. {
  883. this.listViewData_Product.Groups["NotGroup"].Items.Add(lvItem);
  884. }
  885. }
  886. this.listViewData_Product.Items.Add(lvItem);
  887. }
  888. else if (tblProduct.Rows[i]["Pgm_GiveType"].ToString().Trim() == "1")
  889. {
  890. this.HuFuList.Add(String.Format("{0} {1} {2}", lvItem.Text, tblProduct.Rows[i]["Pgm_Quantity"].ToString().Trim(), tblProduct.Rows[i]["Prod_Unit"].ToString().Trim()));
  891. if (this.tabPage2.Parent == null)
  892. {
  893. if (this.listViewData_Service.Groups[tblProduct.Rows[i]["Prod_Class"].ToString().Trim()] != null)
  894. { this.listViewData_Service.Groups[tblProduct.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
  895. }
  896. else
  897. {
  898. if (!string.IsNullOrEmpty(tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()))
  899. {
  900. if (this.listViewData_Service.Groups.Count > 0 && this.listViewData_Service.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()] != null)
  901. { this.listViewData_Service.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()].Items.Add(lvItem); }
  902. else
  903. { this.listViewData_Service.Groups["NotGroup"].Items.Add(lvItem); }
  904. }
  905. else
  906. { this.listViewData_Service.Groups["NotGroup"].Items.Add(lvItem); }
  907. }
  908. this.listViewData_Service.Items.Add(lvItem);
  909. }
  910. }
  911. this.ListViewDrawSingleOrDoubleRows(ListViewType.套系商品);
  912. this.ListViewDrawSingleOrDoubleRows(ListViewType.套系服务);
  913. #endregion
  914. }
  915. else
  916. {
  917. this.lblPakUnitPrice.Text = "套系价格:0";
  918. MessageBoxCustom.Show(this.cmbtreev_PackageName.Text.ToString() + " 此类型无套系名称!请添加套系名称");
  919. this.cmbtreev_PackageName.SetTextAndTag_ValueNull();
  920. }
  921. this.GetSeriesCostsPriceStatistics();
  922. }
  923. /// <summary>
  924. /// 关闭
  925. /// </summary>
  926. /// <param name="sender"></param>
  927. /// <param name="e"></param>
  928. void btnCloseed_Click(object sender, EventArgs e)
  929. {
  930. this.Close();
  931. }
  932. /// <summary>
  933. /// 选择版本获取商品成本价,卖价
  934. /// </summary>
  935. /// <param name="sender"></param>
  936. /// <param name="e"></param>
  937. void TabControl_SelectedIndexChanged(object sender, EventArgs e)
  938. {
  939. if (!this.IsFirstLoad)
  940. {
  941. if (this.TabControl.SelectedTab != null)
  942. {
  943. this.GetSeriesCostsPriceStatistics();
  944. }
  945. }
  946. }
  947. #region
  948. /// <summary>
  949. /// 获取套系成本统计
  950. /// </summary>
  951. void GetSeriesCostsPriceStatistics()
  952. {
  953. decimal CostPrice = 0;
  954. decimal SalePrice = 0;
  955. if (this.TabControl.SelectedTab.Name.Trim() == "tabPage1")
  956. {
  957. this.GetProductPrice(ref CostPrice, ref SalePrice);
  958. this.GetServicePrice(ref CostPrice, ref SalePrice);
  959. this.GetSightsPrice(ref CostPrice, ref SalePrice);
  960. this.lblCostPrice.Text = Convert.ToDecimal(CostPrice).ToString("N2");
  961. this.lblSalePrice.Text = Convert.ToDecimal(SalePrice).ToString("N2");
  962. }
  963. else
  964. {
  965. this.GetProductPrice(ref CostPrice, ref SalePrice);
  966. this.GetServicePrice(ref CostPrice, ref SalePrice);
  967. this.lblCostPrice.Text = Convert.ToDecimal(CostPrice).ToString("N2");
  968. this.lblSalePrice.Text = Convert.ToDecimal(SalePrice).ToString("N2");
  969. }
  970. }
  971. decimal ConvertToDecimal(object obj)
  972. {
  973. try
  974. {
  975. if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
  976. {
  977. decimal outdec = 0.00m;
  978. decimal.TryParse(obj.ToString().Trim(), out outdec);
  979. return outdec;
  980. }
  981. else
  982. {
  983. return 0.00m;
  984. }
  985. }
  986. catch
  987. {
  988. return 0.00m;
  989. }
  990. }
  991. /// <summary>
  992. /// 获取商品成本价
  993. /// </summary>
  994. /// <param name="CostPrice"></param>
  995. /// <param name="SalesPrice"></param>
  996. void GetProductPrice(ref decimal CostPrice, ref decimal SalesPrice)
  997. {
  998. for (int i = 0; i < this.listViewData_Product.Items.Count; i++)
  999. {
  1000. CostPrice += ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["进货价格"].Text.Trim());
  1001. SalesPrice += ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["销售单价"].Text.Trim());
  1002. }
  1003. }
  1004. /// <summary>
  1005. /// 获取服务成本价
  1006. /// </summary>
  1007. /// <param name="CostPrice"></param>
  1008. /// <param name="SalesPrice"></param>
  1009. void GetServicePrice(ref decimal CostPrice, ref decimal SalesPrice)
  1010. {
  1011. for (int i = 0; i < this.listViewData_Service.Items.Count; i++)
  1012. {
  1013. CostPrice += ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["进货价格"].Text.Trim());
  1014. SalesPrice += ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["销售单价"].Text.Trim());
  1015. }
  1016. }
  1017. /// <summary>
  1018. /// 获取景点成本价
  1019. /// </summary>
  1020. /// <param name="CostPrice"></param>
  1021. /// <param name="SalesPrice"></param>
  1022. void GetSightsPrice(ref decimal CostPrice, ref decimal SalesPrice)
  1023. {
  1024. for (int i = 0; i < this.listViewData_Sights.Items.Count; i++)
  1025. {
  1026. CostPrice += ConvertToDecimal(this.listViewData_Sights.Items[i].SubItems["成本单价"].Text.Trim());
  1027. SalesPrice += ConvertToDecimal(this.listViewData_Sights.Items[i].SubItems["销售单价"].Text.Trim());
  1028. }
  1029. }
  1030. /// <summary>
  1031. /// 绘制列表单双行
  1032. /// </summary>
  1033. /// <param name="ProcessType"></param>
  1034. void ListViewDrawSingleOrDoubleRows(ListViewType ProcessType)
  1035. {
  1036. if (ProcessType == ListViewType.套系商品)
  1037. {
  1038. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
  1039. }
  1040. else if (ProcessType == ListViewType.套系服务)
  1041. {
  1042. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Service);
  1043. }
  1044. else if (ProcessType == ListViewType.套系景点)
  1045. {
  1046. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Sights);
  1047. }
  1048. else if (ProcessType == ListViewType.套系次数)
  1049. {
  1050. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Stages);
  1051. }
  1052. }
  1053. #endregion
  1054. enum ListViewType
  1055. {
  1056. 套系商品,
  1057. 套系服务,
  1058. 套系景点,
  1059. 套系次数
  1060. }
  1061. }
  1062. }