FrmProductSet.cs 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. using LYFZ.ComponentLibrary;
  2. using LYFZ.Software.MainBusiness.DoorCityProcess;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. //using System.Web.UI.WebControls;
  12. namespace LYFZ.Software.MainBusiness.InitialSet
  13. {
  14. public partial class FrmProductSet : LYFZ.Software.UI.InitialSet.FrmProductSet
  15. {
  16. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  17. LYFZ.BLL.BLL_ErpProduct ptbll = new BLL.BLL_ErpProduct();
  18. LYFZ.BLL.BLL_ErpPlusPickItems ppisbll = new BLL.BLL_ErpPlusPickItems();
  19. LYFZ.BLL.BLL_ErpWeddingService orwsbll = new BLL.BLL_ErpWeddingService();
  20. LYFZ.BLL.BLL_ErpOrderProductList orptbll = new BLL.BLL_ErpOrderProductList();
  21. public FrmProductSet()
  22. {
  23. this.Load += FrmProductSet_Load;
  24. this.Shown += FrmProductSet_Shown;
  25. this.btnSet.Click += btnSet_Click;
  26. this.btnSupplierSelect.Click += btnSupplierSelect_Click;
  27. this.listViewData_Product.Click += listViewData_Product_Click;
  28. this.btnReset.Click += btnReset_Click;
  29. this.btnDelete.Click += btnDelete_Click;
  30. this.btnClose.Click += btnClose_Click;
  31. this.btnSave.Click += btnSave_Click;
  32. this.btnUnit.Click += btnUnit_Click;
  33. this.btnPicDelete.Click += btnPicDelete_Click;
  34. this.btnUpload.Click += btnUpload_Click;
  35. this.btnQuery.Click += btnQuery_Click;
  36. this.txtQueryText.KeyDown += txtQueryText_KeyDown;
  37. this.cmbtreevProdClassQuery.ComboBoxTree_NodeMouseClick += cmbtreevProdClassQuery_ComboBoxTree_NodeMouseClick;
  38. this.txtProd_PurchasePrice.KeyPress += txtProd_PurchasePrice_KeyPress;
  39. this.txtProd_SalesPrice.KeyPress += txtProd_SalesPrice_KeyPress;
  40. this.txtProd_CostPrice.KeyPress += txtProd_CostPrice_KeyPress;
  41. this.txtProd_Batch.KeyPress += txtProd_Batch_KeyPress;
  42. this.txtProd_AlarmQuantity.KeyPress += txtProd_AlarmQuantity_KeyPress;
  43. this.txtProd_PrintArea.KeyPress += txtProd_PrintArea_KeyPress;
  44. this.txtProd_Name.TextChanged += txtProd_Name_TextChanged;
  45. this.txtProd_Name.KeyPress += txtProd_Name_KeyPress;
  46. this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
  47. this.chkUpperShelves.Click += chkUpperShelves_Click;
  48. this.chkDownShelves.Click += chkDownShelves_Click;
  49. this.picFam_PhotoAlbum.Click += picFam_PhotoAlbum_Click;
  50. this.txtProd_Width.Text = "0";
  51. this.txtProd_Height.Text = "0";
  52. this.btn_UpdateLoad.Click += btn_UpdateLoad_Click;
  53. }
  54. void btn_UpdateLoad_Click(object sender, EventArgs e)
  55. {
  56. if (!string.IsNullOrEmpty(this.txtProd_Name.Text))
  57. {
  58. LYFZ.Software.MainBusiness.Dresses.frmSubmitDataToService submitService = new Dresses.frmSubmitDataToService();
  59. submitService.InitDataInfo(this.txtProd_Name.Tag.ToString(), "Product");
  60. submitService.ShowDialog();
  61. }
  62. }
  63. /// <summary>
  64. /// 相片集合
  65. /// </summary>
  66. ImageList mlistImage = new ImageList();
  67. /// <summary>
  68. /// 窗体加载事件
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. void FrmProductSet_Load(object sender, EventArgs e)
  73. {
  74. this.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  75. this.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  76. this.listViewData_Product.View = View.Details;
  77. this.listViewData_Product.GridLines = true;
  78. string[] StrColumns = "商品名称,单位,进价,卖价,制作费,状态,商品状况".Split(',');
  79. int ColumnOneWidth = (this.listViewData_Product.Width - 23) / 3;
  80. for (int i = 0; i < StrColumns.Length; i++)
  81. {
  82. ColumnHeader ch = new ColumnHeader();
  83. ch.Text = StrColumns[i].Trim();
  84. ch.TextAlign = HorizontalAlignment.Left;
  85. if (i == 0)
  86. { ch.Width = ColumnOneWidth; }
  87. else
  88. { ch.Width = (this.listViewData_Product.Width - 23 - ColumnOneWidth) / 5; }
  89. switch (StrColumns[i].Trim())
  90. {
  91. case "进价":
  92. case "卖价":
  93. case "制作费":
  94. ch.TextAlign = HorizontalAlignment.Right;
  95. break;
  96. default:
  97. ch.TextAlign = HorizontalAlignment.Center;
  98. break;
  99. }
  100. this.listViewData_Product.Columns.Add(ch);
  101. }
  102. this.mlistImage.ImageSize = new Size(30, 30);
  103. this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
  104. this.listViewData_Product.SmallImageList = mlistImage;
  105. this.CreateListViewGroup();
  106. }
  107. /// <summary>
  108. /// 获取商品设置数据
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. void FrmProductSet_Shown(object sender, EventArgs e)
  113. {
  114. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClass);
  115. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClassQuery, IsFirstNodeNull: true, IsFirstNodeName: "全部");
  116. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAG", this.cmbtreevProdUnit, IsFirstNodeNull: true);
  117. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevProdIsEnabled, "上架,下架", IsFirstNodeNull: true);
  118. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevProdAvailability, "减库存,不减库存", IsFirstNodeNull: true);
  119. chkUpperShelves.Checked = true;
  120. //获取商品名称与商品编号
  121. this.PublicFunctionRows();
  122. // 保存新商品
  123. if (this.listViewData_Product.Items.Count == 0)
  124. {
  125. this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ProductCompetence, CustomAttributes.OperatingAuthority.Add);
  126. this.btnSet.Enabled = btnSave.Enabled;
  127. this.btnUnit.Enabled = btnSave.Enabled;
  128. }
  129. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ProductCompetence, CustomAttributes.OperatingAuthority.Delete);
  130. }
  131. /// <summary>
  132. /// 创建默认分组
  133. /// </summary>
  134. void CreateListViewGroup()
  135. {
  136. DataTable dtGroup = orbll.GetView_Custom("tb_ErpProduct Left Join tb_ErpSystemCategory on Prod_Class = Sc_ClassCode", StrWhere: "", ShowColumnName: "Sc_ClassName,Prod_Class", GroupBy: "Sc_ClassName,Prod_Class").Tables[0];
  137. if (dtGroup.Rows.Count > 0)
  138. {
  139. for (int i = 0; i < dtGroup.Rows.Count; i++)
  140. {
  141. if (this.listViewData_Product.Groups[dtGroup.Rows[i]["Prod_Class"].ToString().Trim()] == null)
  142. {
  143. ListViewGroup man_lvg = new ListViewGroup();
  144. man_lvg.Name = dtGroup.Rows[i]["Prod_Class"].ToString().Trim();
  145. man_lvg.Header = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
  146. man_lvg.HeaderAlignment = HorizontalAlignment.Left;
  147. this.listViewData_Product.Groups.Add(man_lvg);
  148. }
  149. }
  150. if (!this.listViewData_Product.ShowGroups)
  151. { this.listViewData_Product.ShowGroups = true; }
  152. }
  153. }
  154. /// <summary>
  155. /// 设置商品类别
  156. /// </summary>
  157. /// <param name="sender"></param>
  158. /// <param name="e"></param>
  159. void btnSet_Click(object sender, EventArgs e)
  160. {
  161. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new FrmSystemSet();
  162. frm.TypeName = "AAAAAAA";
  163. frm.Version = "Version";
  164. if (frm.ShowDialog() == DialogResult.OK)
  165. {
  166. this.cmbtreevProdClass.SetTextAndTag_ValueNull();
  167. this.cmbtreevProdClassQuery.SetTextAndTag_ValueNull();
  168. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClass);
  169. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAA", this.cmbtreevProdClassQuery, IsFirstNodeNull: true, IsFirstNodeName: "全部");
  170. this.CreateListViewGroup();
  171. }
  172. }
  173. /// <summary>
  174. /// 选择供应商
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. void btnSupplierSelect_Click(object sender, EventArgs e)
  179. {
  180. LYFZ.Software.MainBusiness.InitialSet.SetSmallForm.SelectVendorSetSmallForm frm = new SetSmallForm.SelectVendorSetSmallForm();
  181. frm.StrProvideValue = this.txtProd_Vendor.Text.Trim();
  182. frm.ShowDialog();
  183. if (frm.IsSaveed)
  184. { this.txtProd_Vendor.Text = frm.StrSelectedValue.Trim(); }
  185. }
  186. /// <summary>
  187. /// 列表点击事件
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. void listViewData_Product_Click(object sender, EventArgs e)
  192. {
  193. if (this.listViewData_Product.Items.Count > 0 && this.listViewData_Product.SelectedItems.Count > 0)
  194. {
  195. string StrProdcutNumber = this.listViewData_Product.SelectedItems[0].Tag.ToString().Trim();
  196. #region 判断商品是否存在其它表中
  197. //订单商品表
  198. DataTable dt_OrderProductList = orptbll.GetList("OPlist_ProdNumber='" + StrProdcutNumber + "'").Tables[0];
  199. //婚庆服务
  200. DataTable dt_WeddingService = orwsbll.GetList("Ws_ProdNumber='" + StrProdcutNumber + "'").Tables[0];
  201. //二销商品
  202. DataTable dt_PlusPickItems = ppisbll.GetList("Plu_Goods like '%" + StrProdcutNumber + "%'").Tables[0];
  203. if (dt_OrderProductList.Rows.Count > 0 || dt_WeddingService.Rows.Count > 0 || dt_PlusPickItems.Rows.Count > 0)
  204. {
  205. this.txtProd_Name.ReadOnly = true;
  206. this.btnDelete.Enabled = false;
  207. }
  208. else
  209. {
  210. this.txtProd_Name.ReadOnly = false;
  211. this.btnDelete.Enabled = true;
  212. }
  213. #endregion
  214. DataTable dt = ptbll.GetList("Prod_Number='" + StrProdcutNumber + "'").Tables[0];
  215. this.cmbtreevProdClass.TagFindText(dt.Rows[0]["Prod_Class"].ToString().Trim());
  216. this.txtProd_Name.Text = dt.Rows[0]["Prod_Name"].ToString().Trim();
  217. this.txtProd_Name.Tag = dt.Rows[0]["Prod_Number"].ToString().Trim();
  218. this.cmbtreevProdUnit.TextFindTag(dt.Rows[0]["Prod_Unit"].ToString().Trim());
  219. this.txtProd_CostPrice.Text = dt.Rows[0]["Prod_CostPrice"].ToString().Trim();
  220. this.txtProd_SalesPrice.Text = dt.Rows[0]["Prod_SalesPrice"].ToString().Trim();
  221. this.txtProd_PurchasePrice.Text = dt.Rows[0]["Prod_PurchasePrice"].ToString().Trim();
  222. this.txtProd_Remark.Text = dt.Rows[0]["Prod_Remark"].ToString().Trim();
  223. this.txtProd_CostPrice.Text = dt.Rows[0]["Prod_CostPrice"].ToString().Trim();
  224. this.cmbtreevProdIsEnabled.TextFindTag(Convert.ToBoolean(dt.Rows[0]["Prod_IsEnabled"].ToString().Trim()) == true ? "上架" : "下架");
  225. this.txtProd_AlarmQuantity.Text = dt.Rows[0]["Prod_AlarmQuantity"].ToString().Trim();
  226. this.txtProd_Batch.Text = dt.Rows[0]["Prod_Batch"].ToString().Trim();
  227. this.cmbtreevProdAvailability.TextFindTag(dt.Rows[0]["Prod_Availability"].ToString().Trim() == "0" ? "不减库存" : "减库存");
  228. this.txtProd_PrintArea.Text = dt.Rows[0]["Prod_PrintArea"].ToString().Trim();
  229. this.txtProd_Vendor.Text = dt.Rows[0]["Prod_Vendor"].ToString().Trim();
  230. int width = 0, height = 0;
  231. if (int.TryParse(dt.Rows[0]["Prod_Width"].ToString(), out width))
  232. this.txtProd_Width.Text = (width / 10000.0).ToString();
  233. else
  234. this.txtProd_Width.Text = "0";
  235. if (int.TryParse(dt.Rows[0]["Prod_Height"].ToString(), out height))
  236. this.txtProd_Height.Text = (height / 10000.0).ToString();
  237. else
  238. this.txtProd_Height.Text = "0";
  239. if (!string.IsNullOrEmpty(dt.Rows[0]["Prod_Thumbnail"].ToString().Trim()))
  240. {
  241. this.picFam_PhotoAlbum.BeginInvoke((Action)delegate()
  242. { this.picFam_PhotoAlbum.Image = PublicCodeClasses.GetImage(PublicCodeClasses.StringToByte(dt.Rows[0]["Prod_Thumbnail"].ToString().Trim())); });
  243. }
  244. else
  245. { this.picFam_PhotoAlbum.Image = null; }
  246. int pStatus = Convert.ToInt32(dt.Rows[0]["Prod_ProductStatus"]);
  247. if(pStatus==1)
  248. {
  249. this.rdo_Product.Checked = true;
  250. }
  251. else
  252. {
  253. this.rdo_HalfProduct.Checked = true;
  254. }
  255. }
  256. this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ProductCompetence, CustomAttributes.OperatingAuthority.Update);
  257. }
  258. /// <summary>
  259. /// 重置
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. void btnReset_Click(object sender, EventArgs e)
  264. {
  265. this.txtProd_Name.Text = "";
  266. this.txtProd_Name.Tag = null;
  267. this.cmbtreevProdUnit.SetTextAndTag_ValueNull();
  268. this.txtProd_CostPrice.Text = "";
  269. this.txtProd_SalesPrice.Text = "";
  270. this.txtProd_PurchasePrice.Text = "";
  271. this.cmbtreevProdIsEnabled.SetTextAndTag_ValueNull();
  272. this.txtProd_Remark.Text = "";
  273. this.txtProd_AlarmQuantity.Text = "";
  274. this.txtProd_Batch.Text = "0";
  275. this.txtProd_Name.ReadOnly = false;
  276. this.cmbtreevProdAvailability.SetTextAndTag_ValueNull();
  277. this.txtProd_PrintArea.Text = "0";
  278. this.txtProd_Vendor.Text = "";
  279. this.picFam_PhotoAlbum.Image = null;
  280. this.txtProd_Width.Text = "0";
  281. this.txtProd_Height.Text = "0";
  282. this.rdo_Product.Checked = true;
  283. }
  284. /// <summary>
  285. /// 删除商品设置
  286. /// </summary>
  287. /// <param name="sender"></param>
  288. /// <param name="e"></param>
  289. void btnDelete_Click(object sender, EventArgs e)
  290. {
  291. if (this.txtProd_Name.Tag == null)
  292. { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
  293. DataTable dt = ptbll.GetList("Prod_Number='" + this.txtProd_Name.Tag.ToString().Trim() + "'", "ID desc").Tables[0];
  294. if (dt.Rows.Count > 0)
  295. {
  296. int id = Convert.ToInt32(dt.Rows[0]["ID"]);
  297. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  298. {
  299. if (ptbll.Delete(id) == true)
  300. {
  301. #region 写入操作日志
  302. string logsContent = "删除商品名称:" + txtProd_Name.Text.Trim();
  303. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除商品, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  304. #endregion
  305. MessageBoxCustom.Show("删除成功!");
  306. this.btnReset_Click(this, null);
  307. this.listViewData_Product.Items.Remove(this.listViewData_Product.SelectedItems[0]);
  308. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
  309. }
  310. else
  311. { MessageBoxCustom.Show("删除失败!"); }
  312. }
  313. }
  314. else
  315. { MessageBoxCustom.Show("找不到商品'" + this.txtProd_Name.Text.Trim() + "',或已被删除!"); }
  316. }
  317. /// <summary>
  318. /// 关闭页面
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. void btnClose_Click(object sender, EventArgs e)
  323. { this.Close(); }
  324. /// <summary>
  325. /// 保存
  326. /// </summary>
  327. /// <param name="sender"></param>
  328. /// <param name="e"></param>
  329. void btnSave_Click(object sender, EventArgs e)
  330. {
  331. #region 判断资料不能为空
  332. if (string.IsNullOrEmpty(this.cmbtreevProdClass.Text.Trim()))
  333. { MessageBoxCustom.Show("商品类别名称不能为空!"); return; }
  334. if (string.IsNullOrEmpty(this.txtProd_Name.Text.Trim()))
  335. { MessageBoxCustom.Show("商品名称不能为空!"); return; }
  336. if (string.IsNullOrEmpty(this.txtProd_Batch.Text.Trim()))
  337. { MessageBoxCustom.Show("请输入商品的P数"); return; }
  338. if (string.IsNullOrEmpty(this.txtProd_CostPrice.Text.Trim()))
  339. { MessageBoxCustom.Show("商品成本不能为空!"); return; }
  340. if (string.IsNullOrEmpty(this.txtProd_SalesPrice.Text.Trim()))
  341. { MessageBoxCustom.Show("商品卖价不能为空!"); return; }
  342. if (string.IsNullOrEmpty(this.cmbtreevProdIsEnabled.Text.Trim()))
  343. { MessageBoxCustom.Show("状态不能为空!"); return; }
  344. if (string.IsNullOrEmpty(txtProd_AlarmQuantity.Text.Trim()))
  345. { MessageBoxCustom.Show("报警数量不能为空!"); return; }
  346. if (string.IsNullOrEmpty(this.cmbtreevProdAvailability.Text.Trim()))
  347. { MessageBoxCustom.Show("库存状态不能为空!"); return; }
  348. if (this.txtProd_Name.Text.Trim().Length > 50)
  349. { MessageBoxCustom.Show("商品名称长度不能超过50字!"); return; }
  350. #endregion
  351. LYFZ.Model.Model_ErpProduct model = null;
  352. #region 增加
  353. try
  354. {
  355. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  356. if (this.txtProd_Name.Tag == null)
  357. {
  358. if (ptbll.Exists("Prod_Name", this.txtProd_Name.Text))
  359. { MessageBoxCustom.Show("商品名称已经存在!"); return; }
  360. model = new Model.Model_ErpProduct();
  361. model.Prod_Number = LYFZ.BLL.BLL_ErpProduct.GetNewProdNumber();
  362. model.Prod_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID();
  363. model.Prod_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtProd_Name.Text.Trim());
  364. model.Prod_Class = this.cmbtreevProdClass.Tag.ToString();
  365. model.Prod_Unit = this.cmbtreevProdUnit.Text.Trim();
  366. model.Prod_CostPrice = Convert.ToDecimal(this.txtProd_CostPrice.Text);
  367. model.Prod_SalesPrice = Convert.ToDecimal(this.txtProd_SalesPrice.Text);
  368. model.Prod_SpecialPrice = 0;
  369. if (string.IsNullOrEmpty(this.txtProd_PurchasePrice.Text))
  370. { model.Prod_PurchasePrice = 0; }
  371. else
  372. { model.Prod_PurchasePrice = Convert.ToDecimal(this.txtProd_PurchasePrice.Text); }
  373. model.Prod_IsRetail = false;
  374. if (this.cmbtreevProdIsEnabled.Text.Trim() == "下架")
  375. { model.Prod_IsEnabled = false; }
  376. else
  377. { model.Prod_IsEnabled = true; }
  378. model.Prod_Introduction = "";
  379. model.Prod_Detail = "";
  380. model.Prod_Remark = this.txtProd_Remark.Text;
  381. model.Prod_Quantity = 0;
  382. model.Prod_Thumbnail = "";
  383. model.Prod_FullSizeImage = "";
  384. model.Prod_Expedited = false;
  385. model.Prod_CreateDateTime = SDateTime.Now;
  386. model.Prod_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  387. model.Prod_Batch = Convert.ToInt32(this.txtProd_Batch.Text);
  388. model.Prod_ClassName = this.cmbtreevProdClass.Text;
  389. model.Prod_AlarmQuantity = Convert.ToInt32(this.txtProd_AlarmQuantity.Text);
  390. model.Prod_Thumbnail = PublicCodeClasses.ToHexString(PublicCodeClasses.ImageDatabytes(this.picFam_PhotoAlbum));
  391. model.Prod_PrintArea = this.txtProd_PrintArea.Text.Trim();
  392. model.Prod_Vendor = this.txtProd_Vendor.Text.Trim();
  393. model.Prod_Width = (int)(Convert.ToSingle(this.txtProd_Width.Text) * 10000);
  394. model.Prod_Height = (int)(Convert.ToSingle(this.txtProd_Height.Text) * 10000);
  395. if (this.cmbtreevProdAvailability.Text.Trim() == "不减库存")
  396. { model.Prod_Availability = 0; }
  397. else
  398. { model.Prod_Availability = 1; }
  399. model.Prod_ProductStatus = rdo_Product.Checked ? 1 : 0;
  400. clist.Add(ptbll.GetAddCommandInfo(model));
  401. }
  402. else
  403. {
  404. #region 判断商品名称是否存在
  405. if (!string.IsNullOrEmpty(this.txtProd_Name.Text.Trim()))
  406. {
  407. DataTable dt = ptbll.GetList("Prod_Number='" + this.txtProd_Name.Tag.ToString().Trim() + "'", "ID desc").Tables[0];
  408. if (dt.Rows[0]["Prod_Name"].ToString().Trim() != this.txtProd_Name.Text.Trim())
  409. {
  410. dt = ptbll.GetList("Prod_Name='" + this.txtProd_Name.Text.Trim() + "'").Tables[0];
  411. if (dt.Rows.Count > 0)
  412. {
  413. MessageBoxCustom.Show("商品名称已经存在!");
  414. return;
  415. }
  416. }
  417. }
  418. #endregion
  419. DataTable tbl = ptbll.GetList("Prod_Number='" + this.txtProd_Name.Tag.ToString().Trim() + "'", "ID desc").Tables[0];
  420. model = ptbll.DataRowToModel(tbl.Rows[0]);
  421. model.Prod_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtProd_Name.Text.Trim());
  422. model.Prod_ClassName = this.cmbtreevProdClass.Text.Trim();
  423. model.Prod_Class = this.cmbtreevProdClass.Tag.ToString();
  424. if (!string.IsNullOrEmpty(this.cmbtreevProdUnit.Text.Trim()))
  425. { model.Prod_Unit = this.cmbtreevProdUnit.Text.Trim(); }
  426. model.Prod_CostPrice = Convert.ToDecimal(this.txtProd_CostPrice.Text);
  427. model.Prod_SalesPrice = Convert.ToDecimal(this.txtProd_SalesPrice.Text);
  428. if (!string.IsNullOrEmpty(this.txtProd_PurchasePrice.Text))
  429. { model.Prod_PurchasePrice = Convert.ToDecimal(this.txtProd_PurchasePrice.Text); }
  430. if (this.cmbtreevProdIsEnabled.Text.Trim() == "下架")
  431. { model.Prod_IsEnabled = false; }
  432. else
  433. { model.Prod_IsEnabled = true; }
  434. model.Prod_Remark = this.txtProd_Remark.Text;
  435. model.Prod_UpdateDateTime = SDateTime.Now;
  436. model.Prod_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  437. model.Prod_Batch = Convert.ToInt32(this.txtProd_Batch.Text);
  438. model.Prod_AlarmQuantity = Convert.ToInt32(this.txtProd_AlarmQuantity.Text);
  439. if (this.cmbtreevProdAvailability.Text.Trim() == "不减库存")
  440. { model.Prod_Availability = 0; }
  441. else
  442. { model.Prod_Availability = 1; }
  443. model.Prod_Thumbnail = PublicCodeClasses.ToHexString(PublicCodeClasses.ImageDatabytes(this.picFam_PhotoAlbum));
  444. model.Prod_PrintArea = txtProd_PrintArea.Text.Trim();
  445. model.Prod_Vendor = this.txtProd_Vendor.Text.Trim();
  446. model.Prod_Width = (int)(Convert.ToSingle(this.txtProd_Width.Text) * 10000);
  447. model.Prod_Height = (int)(Convert.ToSingle(this.txtProd_Height.Text) * 10000);
  448. model.Prod_ProductStatus = rdo_Product.Checked ? 1 : 0;
  449. clist.Add(ptbll.GetUpdateCommandInfo(model));
  450. }
  451. if (clist.Count > 0)
  452. {
  453. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  454. {
  455. this.CreateListViewGroup();
  456. Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(model.Prod_Thumbnail);
  457. MessageBoxCustom.Show("保存成功!");
  458. if (this.txtProd_Name.Tag == null)
  459. {
  460. this.cmbtreevProdClassQuery.SelectedNode = null;
  461. this.cmbtreevProdClassQuery.TextFindTag("全部");
  462. this.mlistImage.Images.Add(model.Prod_Number.Trim(), img);
  463. }
  464. else
  465. { this.mlistImage.Images.RemoveByKey(model.Prod_Number.Trim()); }
  466. //清空与刷新
  467. this.btnReset_Click(this, null);
  468. this.PublicFunctionRows();
  469. }
  470. else
  471. { MessageBoxCustom.Show("保存失败!"); }
  472. }
  473. }
  474. catch (Exception ex)
  475. { MessageBoxCustom.Show(ex.Message); }
  476. #endregion
  477. }
  478. /// <summary>
  479. /// 设置商品单位
  480. /// </summary>
  481. /// <param name="sender"></param>
  482. /// <param name="e"></param>
  483. void btnUnit_Click(object sender, EventArgs e)
  484. {
  485. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new FrmSystemSet();
  486. frm.TypeName = "AAAAAAG";
  487. frm.Version = "Version";
  488. if (frm.ShowDialog() == DialogResult.OK)
  489. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("AAAAAAG", this.cmbtreevProdUnit, IsFirstNodeNull: true); }
  490. }
  491. /// <summary>
  492. /// 删除图片
  493. /// </summary>
  494. /// <param name="sender"></param>
  495. /// <param name="e"></param>
  496. void btnPicDelete_Click(object sender, EventArgs e)
  497. { this.picFam_PhotoAlbum.Image = null; }
  498. /// <summary>
  499. /// 上传图片
  500. /// </summary>
  501. /// <param name="sender"></param>
  502. /// <param name="e"></param>
  503. void btnUpload_Click(object sender, EventArgs e)
  504. {
  505. openFileDialog1.Filter = "图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
  506. openFileDialog1.FileName = "";
  507. if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  508. { this.picFam_PhotoAlbum.Image = LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(openFileDialog1.FileName.Trim(), 400, 320); }
  509. }
  510. /// <summary>
  511. /// 查询
  512. /// </summary>
  513. /// <param name="sender"></param>
  514. /// <param name="e"></param>
  515. void btnQuery_Click(object sender, EventArgs e)
  516. {
  517. this.PublicFunctionRows();
  518. }
  519. /// <summary>
  520. /// 回车查询
  521. /// </summary>
  522. /// <param name="sender"></param>
  523. /// <param name="e"></param>
  524. void txtQueryText_KeyDown(object sender, KeyEventArgs e)
  525. {
  526. if (e.KeyCode == Keys.Enter)
  527. { this.PublicFunctionRows(); }
  528. }
  529. /// <summary>
  530. /// 商品类别查询
  531. /// </summary>
  532. /// <param name="sender"></param>
  533. /// <param name="e"></param>
  534. void cmbtreevProdClassQuery_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  535. {
  536. this.btnReset_Click(this, null);
  537. this.cmbtreevProdClassQuery.SelectedNode = this.cmbtreevProdClassQuery.GetNodeItem_TextToTag(this.cmbtreevProdClassQuery.Text.Trim());
  538. this.PublicFunctionRows();
  539. }
  540. /// <summary>
  541. /// 输入框设置
  542. /// </summary>
  543. /// <param name="sender"></param>
  544. /// <param name="e"></param>
  545. void txtProd_PurchasePrice_KeyPress(object sender, KeyPressEventArgs e)
  546. {
  547. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  548. { e.Handled = true; }
  549. else if (Char.IsPunctuation(e.KeyChar))
  550. {
  551. if (e.KeyChar == '.')
  552. {
  553. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  554. { e.Handled = true; }
  555. }
  556. else
  557. { e.Handled = true; }
  558. }
  559. }
  560. /// <summary>
  561. /// 输入框设置
  562. /// </summary>
  563. /// <param name="sender"></param>
  564. /// <param name="e"></param>
  565. void txtProd_SalesPrice_KeyPress(object sender, KeyPressEventArgs e)
  566. {
  567. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  568. { e.Handled = true; }
  569. else if (Char.IsPunctuation(e.KeyChar))
  570. {
  571. if (e.KeyChar == '.')
  572. {
  573. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  574. { e.Handled = true; }
  575. }
  576. else
  577. { e.Handled = true; }
  578. }
  579. }
  580. /// <summary>
  581. /// 输入框设置
  582. /// </summary>
  583. /// <param name="sender"></param>
  584. /// <param name="e"></param>
  585. void txtProd_CostPrice_KeyPress(object sender, KeyPressEventArgs e)
  586. {
  587. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  588. { e.Handled = true; }
  589. else if (Char.IsPunctuation(e.KeyChar))
  590. {
  591. if (e.KeyChar == '.')
  592. {
  593. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  594. { e.Handled = true; }
  595. }
  596. else
  597. { e.Handled = true; }
  598. }
  599. }
  600. /// <summary>
  601. /// 输入框设置
  602. /// </summary>
  603. /// <param name="sender"></param>
  604. /// <param name="e"></param>
  605. void txtProd_Batch_KeyPress(object sender, KeyPressEventArgs e)
  606. {
  607. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  608. { e.Handled = true; }
  609. }
  610. /// <summary>
  611. /// 输入框设置
  612. /// </summary>
  613. /// <param name="sender"></param>
  614. /// <param name="e"></param>
  615. void txtProd_AlarmQuantity_KeyPress(object sender, KeyPressEventArgs e)
  616. {
  617. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  618. { e.Handled = true; }
  619. }
  620. /// <summary>
  621. /// 输入框设置
  622. /// </summary>
  623. /// <param name="sender"></param>
  624. /// <param name="e"></param>
  625. void txtProd_PrintArea_KeyPress(object sender, KeyPressEventArgs e)
  626. {
  627. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  628. { e.Handled = true; }
  629. else if (Char.IsPunctuation(e.KeyChar))
  630. {
  631. if (e.KeyChar == '.')
  632. {
  633. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  634. { e.Handled = true; }
  635. }
  636. else
  637. { e.Handled = true; }
  638. }
  639. }
  640. /// <summary>
  641. /// 商品名称输入限制
  642. /// </summary>
  643. /// <param name="sender"></param>
  644. /// <param name="e"></param>
  645. void txtProd_Name_TextChanged(object sender, EventArgs e)
  646. {
  647. string Prod_Name = txtProd_Name.Text;
  648. if (!string.IsNullOrEmpty(Prod_Name))
  649. {
  650. if (Prod_Name.ToUpper().Contains("\t") ||
  651. Prod_Name.ToUpper().Contains(":") ||
  652. Prod_Name.ToUpper().Contains("?") ||
  653. Prod_Name.ToUpper().Contains("\"") ||
  654. Prod_Name.ToUpper().Contains("<") ||
  655. Prod_Name.ToUpper().Contains(">") ||
  656. Prod_Name.ToUpper().Contains("|") ||
  657. Prod_Name.ToUpper().Contains("\\") ||
  658. Prod_Name.ToUpper().Contains("/") ||
  659. // Prod_Name.ToUpper().Contains("(") ||
  660. // Prod_Name.ToUpper().Contains(")") ||
  661. Prod_Name.ToUpper().Contains("*") ||
  662. Prod_Name.ToUpper().Contains(",") ||
  663. Prod_Name.ToUpper().Contains('"'))
  664. {
  665. MessageBoxCustom.Show("此名称有不合法字符!");
  666. txtProd_Name.Text = "";
  667. return;
  668. }
  669. }
  670. }
  671. /// <summary>
  672. /// 商品名称输入限制
  673. /// </summary>
  674. /// <param name="sender"></param>
  675. /// <param name="e"></param>
  676. void txtProd_Name_KeyPress(object sender, KeyPressEventArgs e)
  677. {
  678. //2017-04-03 刘工 修改允许商品名中输 ()和. 【】[]
  679. if (!Char.IsNumber(e.KeyChar)
  680. && !Char.IsControl(e.KeyChar)
  681. && !Char.IsLetterOrDigit(e.KeyChar)
  682. && e.KeyChar != (char)'_'
  683. && e.KeyChar != (char)' '
  684. && e.KeyChar != (char)'('
  685. && e.KeyChar != (char)')'
  686. && e.KeyChar != (char)'.'
  687. && e.KeyChar != (char)'['
  688. && e.KeyChar != (char)']'
  689. && e.KeyChar != (char)'【'
  690. && e.KeyChar != (char)'】'
  691. )
  692. {
  693. e.Handled = true;
  694. }
  695. }
  696. /// <summary>
  697. /// 上架
  698. /// </summary>
  699. /// <param name="sender"></param>
  700. /// <param name="e"></param>
  701. void chkUpperShelves_Click(object sender, EventArgs e)
  702. {
  703. this.btnReset_Click(this, null);
  704. this.chkDownShelves.Checked = false;
  705. this.PublicFunctionRows();
  706. }
  707. /// <summary>
  708. /// 下架
  709. /// </summary>
  710. /// <param name="sender"></param>
  711. /// <param name="e"></param>
  712. void chkDownShelves_Click(object sender, EventArgs e)
  713. {
  714. this.btnReset_Click(this, null);
  715. this.chkUpperShelves.Checked = false;
  716. this.PublicFunctionRows();
  717. }
  718. /// <summary>
  719. /// 获取商品名称与商品编号
  720. /// </summary>
  721. private void PublicFunctionRows()
  722. {
  723. #region 一次性获取
  724. //string StrOrderBy = "";
  725. //string StrWhere = this.GetStrWhere();
  726. //if (StrWhere.Trim().Equals("1=1"))
  727. //{ StrOrderBy = "Prod_Class desc"; }
  728. //else
  729. //{ StrOrderBy = "ID desc"; }
  730. //this.listViewData_Product.Items.Clear();
  731. //DataTable newTable = orbll.GetView_Custom("tb_ErpProduct", StrWhere: StrWhere, ShowColumnName: "Prod_Number,Prod_Class,Prod_Name,Prod_Unit,Prod_CostPrice,Prod_SalesPrice,Prod_PurchasePrice,Prod_IsEnabled", filedOrder: StrOrderBy).Tables[0];
  732. //for (int i = 0; i < newTable.Rows.Count; i++)
  733. //{
  734. // ListViewItem lvItem = new ListViewItem();
  735. // Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage("");
  736. // this.mlistImage.Images.Add(newTable.Rows[i]["Prod_Number"].ToString().Trim(), img);
  737. // lvItem.Tag = newTable.Rows[i]["Prod_Number"].ToString().Trim();
  738. // lvItem.ImageKey = newTable.Rows[i]["Prod_Number"].ToString().Trim();
  739. // lvItem.Text = newTable.Rows[i]["Prod_Name"].ToString().Trim();
  740. // ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  741. // ListSubItem.Name = "商品名称";
  742. // ListSubItem.Text = newTable.Rows[i]["Prod_Unit"].ToString().Trim();
  743. // lvItem.SubItems.Add(ListSubItem);
  744. // ListSubItem = new ListViewItem.ListViewSubItem();
  745. // ListSubItem.Name = "进价";
  746. // ListSubItem.Text = newTable.Rows[i]["Prod_CostPrice"].ToString().Trim();
  747. // lvItem.SubItems.Add(ListSubItem);
  748. // ListSubItem = new ListViewItem.ListViewSubItem();
  749. // ListSubItem.Name = "卖价";
  750. // ListSubItem.Text = newTable.Rows[i]["Prod_SalesPrice"].ToString().Trim();
  751. // lvItem.SubItems.Add(ListSubItem);
  752. // ListSubItem = new ListViewItem.ListViewSubItem();
  753. // ListSubItem.Name = "制作费";
  754. // ListSubItem.Text = newTable.Rows[i]["Prod_PurchasePrice"].ToString().Trim();
  755. // lvItem.SubItems.Add(ListSubItem);
  756. // ListSubItem = new ListViewItem.ListViewSubItem();
  757. // ListSubItem.Name = "状态";
  758. // ListSubItem.Text = Convert.ToBoolean(newTable.Rows[i]["Prod_IsEnabled"]) ? "上架" : "下架";
  759. // lvItem.SubItems.Add(ListSubItem);
  760. // if (this.listViewData_Product.Groups.Count > 0)
  761. // { this.listViewData_Product.Groups[newTable.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
  762. // this.listViewData_Product.Items.Add(lvItem);
  763. //}
  764. #endregion
  765. this.ucPagerEx1.PageCurrent = 1;
  766. this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();
  767. this.ucPagerEx1.Bind();
  768. }
  769. /// <summary>
  770. /// 画分页
  771. /// </summary>
  772. /// <param name="e"></param>
  773. /// <returns></returns>
  774. private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
  775. {
  776. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  777. pageData.PageIndex = this.ucPagerEx1.PageCurrent;
  778. pageData.PageSize = this.ucPagerEx1.PageSize;
  779. this.listViewData_Product.Items.Clear();
  780. DataTable dt = new DataTable();
  781. string StrWhere = this.GetStrWhere();
  782. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  783. {
  784. pageData.TableName = "tb_ErpProduct";
  785. pageData.QueryCondition = StrWhere;
  786. pageData.QueryFieldName = "Prod_Number,Prod_Class,Prod_Name,Prod_Unit,Prod_CostPrice,Prod_SalesPrice,Prod_PurchasePrice,Prod_IsEnabled,Prod_Thumbnail,Prod_ProductStatus";
  787. if (StrWhere.Trim().Equals("1=1"))
  788. { pageData.OrderStr = "Prod_Class desc,Prod_Number "; }
  789. else
  790. { pageData.OrderStr = "ID desc"; }
  791. pageData.OrderType = 1;
  792. dt = pageData.QueryDataTable().Tables[0];
  793. for (int i = 0; i < dt.Rows.Count; i++)
  794. {
  795. if (!this.mlistImage.Images.Keys.Contains(dt.Rows[i]["Prod_Number"].ToString().Trim()))
  796. {
  797. Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(dt.Rows[i]["Prod_Thumbnail"].ToString().Trim());
  798. this.mlistImage.Images.Add(dt.Rows[i]["Prod_Number"].ToString().Trim(), img);
  799. }
  800. }
  801. });
  802. for (int i = 0; i < dt.Rows.Count; i++)
  803. {
  804. ListViewItem lvItem = new ListViewItem();
  805. lvItem.Tag = dt.Rows[i]["Prod_Number"].ToString().Trim();
  806. lvItem.ImageKey = dt.Rows[i]["Prod_Number"].ToString().Trim();
  807. lvItem.Text = dt.Rows[i]["Prod_Name"].ToString().Trim();
  808. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  809. ListSubItem.Name = "商品名称";
  810. ListSubItem.Text = dt.Rows[i]["Prod_Unit"].ToString().Trim();
  811. lvItem.SubItems.Add(ListSubItem);
  812. ListSubItem = new ListViewItem.ListViewSubItem();
  813. ListSubItem.Name = "进价";
  814. ListSubItem.Text = dt.Rows[i]["Prod_CostPrice"].ToString().Trim();
  815. lvItem.SubItems.Add(ListSubItem);
  816. ListSubItem = new ListViewItem.ListViewSubItem();
  817. ListSubItem.Name = "卖价";
  818. ListSubItem.Text = dt.Rows[i]["Prod_SalesPrice"].ToString().Trim();
  819. lvItem.SubItems.Add(ListSubItem);
  820. ListSubItem = new ListViewItem.ListViewSubItem();
  821. ListSubItem.Name = "制作费";
  822. ListSubItem.Text = dt.Rows[i]["Prod_PurchasePrice"].ToString().Trim();
  823. lvItem.SubItems.Add(ListSubItem);
  824. ListSubItem = new ListViewItem.ListViewSubItem();
  825. ListSubItem.Name = "状态";
  826. ListSubItem.Text = Convert.ToBoolean(dt.Rows[i]["Prod_IsEnabled"]) ? "上架" : "下架";
  827. lvItem.SubItems.Add(ListSubItem);
  828. ListSubItem = new ListViewItem.ListViewSubItem();
  829. ListSubItem.Name = "商品状况";
  830. ListSubItem.Text = Convert.ToInt32(dt.Rows[i]["prod_ProductStatus"])==1 ? "成品" : "半成品";
  831. lvItem.SubItems.Add(ListSubItem);
  832. if (this.listViewData_Product.Groups.Count > 0)
  833. { this.listViewData_Product.Groups[dt.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
  834. this.listViewData_Product.Items.Add(lvItem);
  835. }
  836. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
  837. this.ucPagerEx1.TbDataSource = dt;
  838. return pageData.TotalCount;
  839. }
  840. /// <summary>
  841. /// 获取查询条件
  842. /// </summary>
  843. /// <returns></returns>
  844. string GetStrWhere()
  845. {
  846. string StrWhere = "1=1";
  847. if (this.chkUpperShelves.Checked)
  848. { StrWhere += " and Prod_IsEnabled = 1"; }
  849. else if (this.chkDownShelves.Checked)
  850. { StrWhere += " and Prod_IsEnabled = 0"; }
  851. if (!string.IsNullOrEmpty(this.txtQueryText.Text.Trim()))
  852. { StrWhere += " and (Prod_Name like '%" + txtQueryText.Text.Trim() + "%' or dbo.fn_ChineseToSpell(Prod_Name) like '%" + txtQueryText.Text.Trim() + "%')"; }
  853. if (this.cmbtreevProdClassQuery.Text != "全部" && this.cmbtreevProdClassQuery.Text != "")
  854. {
  855. if (this.cmbtreevProdClassQuery.Nodes.Count > 0)
  856. {
  857. string classString = "'" + this.cmbtreevProdClassQuery.Tag.ToString().Trim() + "',";
  858. for (int i = 0; i < this.cmbtreevProdClassQuery.SelectedNode.Nodes.Count; i++)
  859. {
  860. if (this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes.Count > 0)
  861. {
  862. for (int j = 0; j < this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes.Count; j++)
  863. {
  864. if (this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Nodes.Count > 0)
  865. {
  866. for (int k = 0; k < this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Nodes.Count; k++)
  867. { classString += "'" + this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Nodes[k].Tag.ToString().Trim() + "',"; }
  868. }
  869. else
  870. { classString += "'" + this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Nodes[j].Tag.ToString().Trim() + "',"; }
  871. }
  872. }
  873. else
  874. { classString += "'" + this.cmbtreevProdClassQuery.SelectedNode.Nodes[i].Tag.ToString().Trim() + "',"; }
  875. }
  876. StrWhere += " And Prod_Class in(" + classString.TrimEnd(',') + ")";
  877. }
  878. }
  879. return StrWhere;
  880. }
  881. /// <summary>
  882. /// 查看原图
  883. /// </summary>
  884. /// <param name="sender"></param>
  885. /// <param name="e"></param>
  886. void picFam_PhotoAlbum_Click(object sender, EventArgs e)
  887. {
  888. if (this.picFam_PhotoAlbum.Image != null)
  889. {
  890. LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic set = new Product.FrmProductPic();
  891. set.FrmImage = this.picFam_PhotoAlbum.Image;
  892. set.ShowDialog();
  893. }
  894. }
  895. }
  896. }