FrmAttractionsSet.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  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.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. namespace LYFZ.Software.MainBusiness.InitialSet
  13. {
  14. public partial class FrmAttractionsSet : LYFZ.Software.UI.InitialSet.FrmAttractionsSet
  15. {
  16. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  17. LYFZ.BLL.BLL_ErpTheScenery tsbll = new BLL.BLL_ErpTheScenery();
  18. LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
  19. LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
  20. LYFZ.BLL.BLL_ErpSystemLogs systemLogsBll = new BLL.BLL_ErpSystemLogs();
  21. public FrmAttractionsSet(string StrType = "0")
  22. {
  23. if (!string.IsNullOrEmpty(StrType))
  24. { this.StrPackagesType = Convert.ToInt32(StrType); }
  25. else
  26. { this.StrPackagesType = 0; }
  27. this.dgv.CellMouseDoubleClick += dgv_CellMouseDoubleClick;
  28. this.btnBrowse.Click += btnBrowse_Click;
  29. this.lstvData.MouseDoubleClick += lstvData_MouseDoubleClick;
  30. this.btnDeletePhoto.Click += btnDeletePhoto_Click;
  31. // 是否是管理员admin账号;
  32. if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Account.ToLower() == "admin")
  33. {
  34. this.btnUpdateScenery.Click += BtnUpdateScenery_Click;
  35. }
  36. else
  37. {
  38. this.btnUpdateScenery.Visible = false;
  39. }
  40. }
  41. private void BtnUpdateScenery_Click(object sender, EventArgs e)
  42. {
  43. MessageBoxCustom.Show("更新前, 请做好数据库的备份!");
  44. string strUpdateSQL = " with t as ( select " +
  45. "Ordpg_Number as 订单号, "+
  46. "Ordpg_Sights as 订单景点名, "+
  47. "Ordpg_SightsLevel as 订单景点比例, "+
  48. "Tsc_Rating as 系统景点比重 from"+
  49. "[tb_ErpOrdersPhotography] left join[tb_ErpTheScenery] on Tsc_Name = Ordpg_Sights "+
  50. "where Ordpg_SightsLevel<> Tsc_Rating or Ordpg_SightsLevel is null "+
  51. ")update t set 订单景点比例 = 系统景点比重";
  52. if ( LYFZ.Helper.SQLHelper.ExecuteSql(strUpdateSQL) >= 0 )
  53. MessageBoxCustom.Show("更新成功!");
  54. }
  55. /// <summary>
  56. /// 套系大类类型(0:订单景点,1:礼包景点)
  57. /// </summary>
  58. public int StrPackagesType;
  59. /// <summary>
  60. /// 景点类型(0:景点,1:次数)
  61. /// </summary>
  62. public string StrSightsType;
  63. string StrTableName = "tb_ErpTheScenery Left Join tb_ErpSystemCategory on Sc_ClassCode = Tsc_Rating";
  64. string StrColumns = "tb_ErpTheScenery.ID,Tsc_Name,Tsc_Type,Tcs_Category,Tsc_PackagesMainClass,Tsc_Rating,Sc_ClassName AS Tsc_RatingName,Tsc_Introduction,Tsc_DetailsOf,Tsc_Address,Tsc_CostPrice,Tsc_SalesPrice," +
  65. "Tsc_Remark,Tsc_Thumbnail,Tsc_PhotoAlbum,Tsc_IsDisable,Tsc_CreateDatetime,Tsc_CreateName,Tsc_UpdateDatetime,Tsc_UpdateName,CASE Tcs_Category WHEN 0 THEN '内景' ELSE '外景' END AS Tcs_CategoryName,case when Tsc_IsDisable = 0 then '显示' else '隐藏' end Tsc_IsDisableName";
  66. /// <summary>
  67. /// 窗体加载事件
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. protected override void FrmAttractionsSet_Load(object sender, EventArgs e)
  72. {
  73. if (this.StrPackagesType == 0)
  74. { this.Text = "拍摄名称设置"; }
  75. else
  76. { this.Text = "拍摄名称(礼包)设置"; }
  77. if (!string.IsNullOrEmpty(this.StrSightsType))
  78. {
  79. if (this.StrSightsType.ToString() == "0")
  80. {
  81. this.tab.TabPages.RemoveAt(1);
  82. this.GetAttractions();
  83. }
  84. if (this.StrSightsType.ToString() == "1")
  85. {
  86. this.tab.TabPages.RemoveAt(0);
  87. this.GetAttractionsCs();
  88. }
  89. }
  90. else
  91. {
  92. this.GetAttractions();
  93. this.GetAttractionsCs();
  94. }
  95. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevIsDisable, "0:显示,1:隐藏", IsSplit: true);
  96. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboxTreeView(this.cmbtreevIsDisable2, "0:显示,1:隐藏", IsSplit: true);
  97. }
  98. /// <summary>
  99. /// 窗体加载事件
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. protected override void FrmAttractionsSet_Shown(object sender, EventArgs e)
  104. {
  105. if (this.dgv.SelectedRows.Count == 0 || this.dgv2.SelectedRows.Count == 0)
  106. {
  107. this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Add);
  108. this.btnAdd.Enabled = this.btnSave.Enabled;
  109. this.btnSave2.Enabled = this.btnSave.Enabled;
  110. this.btnAdd2.Enabled = this.btnSave.Enabled;
  111. }
  112. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Delete);
  113. this.btnDelete2.Enabled = this.btnDelete.Enabled;
  114. //绑定景点等级
  115. DataTable dt2 = scbll.GetList("Sc_ClassCode = 'BEBBBCADFEBEJBGD'").Tables[0];
  116. if (dt2.Rows.Count > 0)
  117. {
  118. DataTable dt = scbll.GetList("Sc_ClassParentID=" + dt2.Rows[0]["ID"] + "", "Id asc").Tables[0];
  119. for (int i = 0; i < dt.Rows.Count; i++)
  120. {
  121. this.cmbTsc_Rating.Items.Add(new ListItem(dt.Rows[i]["Sc_ClassName"].ToString(), dt.Rows[i]["Sc_ClassCode"]));
  122. this.cmbTsc_Rating2.Items.Add(new ListItem(dt.Rows[i]["Sc_ClassName"].ToString(), dt.Rows[i]["Sc_ClassCode"]));
  123. }
  124. }
  125. this.ImageList1.ColorDepth = ColorDepth.Depth32Bit;
  126. this.ImageList1.ImageSize = new Size(65, 65);
  127. this.lstvData.View = View.LargeIcon;
  128. this.lstvData.LargeImageList = this.ImageList1;
  129. this.GetPhotoData(this.txtTsc_Name.Text.Trim());
  130. }
  131. /// <summary>
  132. /// 获取景点数据
  133. /// </summary>
  134. public void GetAttractions()
  135. {
  136. string StrWhere = " And Tsc_PackagesMainClass = '" + this.StrPackagesType + "'";
  137. DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "Tsc_Type = '0'", ShowColumnName: StrColumns).Tables[0];
  138. //DataTable dt = tsbll.View_ErpTheScenery("Tsc_Type = '0' And Tsc_PackagesMainClass = '"+this.StrPackagesType+"'").Tables[0];
  139. this.dgv.AutoGenerateColumns = false;
  140. this.dgv.DataSource = dt;
  141. this.dgv.ClearSelection();
  142. }
  143. /// <summary>
  144. /// 获取次数数据
  145. /// </summary>
  146. public void GetAttractionsCs()
  147. {
  148. string StrWhere = " And Tsc_PackagesMainClass = '" + this.StrPackagesType + "'";
  149. DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "Tsc_Type='1'", ShowColumnName: StrColumns).Tables[0];
  150. //DataTable dt = tsbll.View_ErpTheScenery("Tsc_Type='1' And Tsc_PackagesMainClass = '" + this.StrPackagesType + "'").Tables[0];
  151. this.dgv2.AutoGenerateColumns = false;
  152. this.dgv2.DataSource = dt;
  153. this.dgv2.ClearSelection();
  154. }
  155. /// <summary>
  156. /// 显示控件单击事件
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. void dgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  161. {
  162. try
  163. {
  164. if (this.dgv.SelectedRows.Count > 0)
  165. {
  166. //更新赋值
  167. string ID = this.dgv.CurrentRow.Cells["ID"].Value.ToString();
  168. DataTable dt = tsbll.GetList("ID='" + ID + "'").Tables[0];
  169. this.txtTsc_Name.Text = dt.Rows[0]["Tsc_Name"].ToString();
  170. this.txtTsc_Name.Tag = ID;
  171. this.txtTsc_Address.Text = dt.Rows[0]["Tsc_Address"].ToString();
  172. this.txtTsc_CostPrice.Text = dt.Rows[0]["Tsc_CostPrice"].ToString();
  173. this.txtTsc_SalesPrice.Text = dt.Rows[0]["Tsc_SalesPrice"].ToString();
  174. this.txtTsc_Remark.Text = dt.Rows[0]["Tsc_Remark"].ToString();
  175. this.cmbtreevIsDisable.TagFindText(dt.Rows[0]["Tsc_IsDisable"].ToString().Trim());
  176. this.cmbTsc_Rating.SelectedItem = ListItem.ValueFindByText(this.cmbTsc_Rating, dt.Rows[0]["Tsc_Rating"].ToString());
  177. if (Convert.ToInt32(dt.Rows[0]["Tcs_Category"]) == 0)
  178. { this.cmbTcs_Category.Text = "内景"; }
  179. else
  180. { this.cmbTcs_Category.Text = "外景"; }
  181. this.btnSave.Text = " 修 改";
  182. //更新商品权限
  183. this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Update);
  184. this.GetPhotoData(this.txtTsc_Name.Text.Trim());
  185. }
  186. }
  187. catch (Exception ex)
  188. { MessageBoxCustom.Show(ex.Message); }
  189. }
  190. /// <summary>
  191. /// 保存景点
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. protected override void btnSave_Click(object sender, EventArgs e)
  196. {
  197. #region 判断资料不能为空
  198. if (string.IsNullOrEmpty(this.txtTsc_Name.Text.Trim()))
  199. { MessageBoxCustom.Show("景点名称不能为空!"); this.txtTsc_Name.Focus(); return; }
  200. if (string.IsNullOrEmpty(this.txtTsc_CostPrice.Text.Trim()))
  201. { MessageBoxCustom.Show("景点成本价不能为空!"); return; }
  202. if (string.IsNullOrEmpty(this.txtTsc_SalesPrice.Text.Trim()))
  203. { MessageBoxCustom.Show("景点摄影报价不能为空!"); return; }
  204. if (string.IsNullOrEmpty(this.cmbTsc_Rating.Text.Trim()))
  205. { MessageBoxCustom.Show("景点等级不能为空!"); return; }
  206. if (string.IsNullOrEmpty(cmbTcs_Category.Text.Trim()))
  207. { MessageBoxCustom.Show("景点所属类别不能为空!"); return; }
  208. if (string.IsNullOrEmpty(this.cmbtreevIsDisable.Text.Trim()))
  209. { MessageBoxCustom.Show("景点是否启用不能为空!"); return; }
  210. if (string.IsNullOrEmpty(this.cmbtreevIsDisable.Text.Trim()))
  211. { MessageBoxCustom.Show("景点是否启用不能为空!"); return; }
  212. if (this.txtTsc_Name.Text.Trim().Length > 20)
  213. { MessageBoxCustom.Show("景点名称长度不能超过20字!"); return; }
  214. #endregion
  215. #region 增加、修改
  216. try
  217. {
  218. if (this.txtTsc_Name.Tag == null)
  219. {
  220. #region 判断景点名称是否存在
  221. //if (tsbll.Exists("Tsc_Name", this.txtTsc_Name.Text) == true)
  222. if (tsbll.GetList("Tsc_Name = '" + this.txtTsc_Name.Text.Trim() + "' and Tsc_Type = '0'").Tables[0].Rows.Count > 0)
  223. {
  224. MessageBoxCustom.Show("景点名称已经存在!");
  225. this.txtTsc_Name.Text = "";
  226. this.txtTsc_Name.Focus();
  227. return;
  228. }
  229. #endregion
  230. LYFZ.Model.Model_ErpTheScenery model = new Model.Model_ErpTheScenery();
  231. model.Tsc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  232. model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name.Text.Trim());
  233. model.Tsc_Type = "0";
  234. if (cmbTcs_Category.Text == "内景")
  235. { model.Tcs_Category = 0; }
  236. else
  237. { model.Tcs_Category = 1; }
  238. model.Tsc_PackagesMainClass = this.StrPackagesType;
  239. model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating.SelectedItem).StrValue.ToString().Trim();
  240. model.Tsc_Address = txtTsc_Address.Text;
  241. model.Tsc_CostPrice = Convert.ToDecimal(txtTsc_CostPrice.Text);
  242. model.Tsc_SalesPrice = Convert.ToDecimal(txtTsc_SalesPrice.Text);
  243. model.Tsc_IsDisable = this.cmbtreevIsDisable.Tag.ToString().Trim();
  244. model.Tsc_Remark = txtTsc_Remark.Text;
  245. model.Tsc_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  246. model.Tsc_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  247. if (!tsbll.Add(model))
  248. { MessageBoxCustom.Show("保存失败!"); return; }
  249. }
  250. else
  251. {
  252. #region 判断景点名称是否存在
  253. if (!string.IsNullOrEmpty(txtTsc_Name.Text.Trim()))
  254. {
  255. DataTable dt = tsbll.GetList("ID=" + dgv.CurrentRow.Cells["ID"].Value.ToString() + "", "ID desc").Tables[0];
  256. string Tsc_Name = dt.Rows[0]["Tsc_Name"].ToString();
  257. if (Tsc_Name != txtTsc_Name.Text.Trim())
  258. {
  259. dt = tsbll.GetList("Tsc_Name='" + txtTsc_Name.Text.Trim() + "'").Tables[0];
  260. if (dt.Rows.Count > 0)
  261. { MessageBoxCustom.Show("景点名称已经存在!"); return; }
  262. }
  263. }
  264. #endregion
  265. LYFZ.Model.Model_ErpTheScenery model = tsbll.GetModel(Convert.ToInt32(this.txtTsc_Name.Tag));
  266. model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name.Text.Trim());
  267. if (cmbTcs_Category.Text == "内景")
  268. { model.Tcs_Category = 0; }
  269. else
  270. { model.Tcs_Category = 1; }
  271. model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating.SelectedItem).StrValue.ToString().Trim();
  272. model.Tsc_Address = txtTsc_Address.Text;
  273. model.Tsc_CostPrice = Convert.ToDecimal(txtTsc_CostPrice.Text);
  274. model.Tsc_SalesPrice = Convert.ToDecimal(txtTsc_SalesPrice.Text);
  275. model.Tsc_Remark = txtTsc_Remark.Text;
  276. model.Tsc_IsDisable = this.cmbtreevIsDisable.Tag.ToString().Trim();
  277. model.Tsc_UpdateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  278. model.Tsc_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  279. if (!tsbll.Update(model))
  280. { MessageBoxCustom.Show("保存失败!"); return; }
  281. }
  282. this.GetAttractions();
  283. this.btnAdd_Click(this, null);
  284. MessageBoxCustom.Show("保存成功!");
  285. }
  286. catch (Exception ex)
  287. { MessageBoxCustom.Show(ex.Message); }
  288. #endregion
  289. }
  290. /// <summary>
  291. /// 删除景点
  292. /// </summary>
  293. /// <param name="sender"></param>
  294. /// <param name="e"></param>
  295. protected override void btnDelete_Click(object sender, EventArgs e)
  296. {
  297. try
  298. {
  299. if (this.dgv.SelectedRows.Count == 0)
  300. { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
  301. //if (Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value) == 1)
  302. //{ MessageBoxCustom.Show("此景点不能删除!"); return; }
  303. int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
  304. DataTable dt = orbll.GetView_Custom("tb_ErpTheScenery", StrWhere: "ID = '" + id + "'", ShowColumnName: "Tsc_Name").Tables[0];
  305. if (dt.Rows.Count > 0)
  306. {
  307. DataTable tbl = orbll.GetView_Custom("tb_ErpOrdersPhotography", StrWhere: "Ordpg_Sights = '" + dt.Rows[0]["Tsc_Name"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
  308. if (tbl.Rows.Count > 0)
  309. { MessageBoxCustom.Show("此景点已有订单选中,不能删除!"); return; }
  310. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  311. {
  312. if (tsbll.Delete(id) == true)
  313. {
  314. #region 写入操作日志
  315. string logsContent = "删除景点名称:" + txtTsc_Name.Text.Trim();
  316. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除景点, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  317. #endregion
  318. #region 删除相片
  319. List<string> strList = new List<string>();
  320. for (int i = 0; i < lstvData.Items.Count; i++)
  321. { strList.Add(lstvData.Items[i].Tag.ToString().Trim()); }
  322. for (int i = 0; i < lstvData.Items.Count; i++)
  323. {
  324. string[] StrArray = lstvData.Items[i].Tag.ToString().Trim().Split('_');
  325. string StrSmall = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DecryptDES(StrArray[1].Trim());
  326. string StrOriginal = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DecryptDES(StrArray[0].Trim());
  327. try
  328. {
  329. if (System.IO.File.Exists(StrOriginal))
  330. { System.IO.File.Delete(StrOriginal); }
  331. }
  332. catch (Exception ex)
  333. { MessageBoxCustom.Show(ex.Message); break; }
  334. try
  335. {
  336. if (System.IO.File.Exists(StrSmall))
  337. { System.IO.File.Delete(StrSmall); }
  338. }
  339. catch (Exception ex)
  340. { MessageBoxCustom.Show(ex.Message); break; }
  341. }
  342. this.GetPhotoData(this.txtTsc_Name.Text.Trim());
  343. #endregion
  344. MessageBoxCustom.Show("删除成功!");
  345. this.btnAdd_Click(this, null);
  346. }
  347. else
  348. { MessageBoxCustom.Show("删除失败!"); }
  349. this.GetAttractions();
  350. }
  351. }
  352. else
  353. { MessageBoxCustom.Show("景点已不存在或已被删除!"); }
  354. }
  355. catch (Exception ex)
  356. { MessageBoxCustom.Show(ex.Message); }
  357. }
  358. /// <summary>
  359. /// 设置文本框
  360. /// </summary>
  361. /// <param name="sender"></param>
  362. /// <param name="e"></param>
  363. protected override void txtTsc_SalesPrice_KeyPress(object sender, KeyPressEventArgs e)
  364. {
  365. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  366. { e.Handled = true; }
  367. else if (Char.IsPunctuation(e.KeyChar))
  368. {
  369. if (e.KeyChar == '.')
  370. {
  371. if (((TextBox)sender).Text.LastIndexOf('.') != -1)
  372. { e.Handled = true; }
  373. }
  374. else
  375. { e.Handled = true; }
  376. }
  377. }
  378. /// <summary>
  379. /// 设置文本框
  380. /// </summary>
  381. /// <param name="sender"></param>
  382. /// <param name="e"></param>
  383. protected override void txtTsc_CostPrice_KeyPress(object sender, KeyPressEventArgs e)
  384. {
  385. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  386. { e.Handled = true; }
  387. else if (Char.IsPunctuation(e.KeyChar))
  388. {
  389. if (e.KeyChar == '.')
  390. {
  391. if (((TextBox)sender).Text.LastIndexOf('.') != -1)
  392. { e.Handled = true; }
  393. }
  394. else
  395. { e.Handled = true; }
  396. }
  397. }
  398. /// <summary>
  399. /// 重置
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. protected override void btnAdd_Click(object sender, EventArgs e)
  404. {
  405. this.txtTsc_Name.Text = "";
  406. this.txtTsc_Name.Tag = null;
  407. this.txtTsc_Address.Text = "";
  408. this.txtTsc_CostPrice.Text = "";
  409. this.txtTsc_SalesPrice.Text = "";
  410. this.txtTsc_Remark.Text = "";
  411. this.cmbTcs_Category.Text = "";
  412. this.cmbTsc_Rating.SelectedItem = null;
  413. this.cmbtreevIsDisable.TagFindText("0");
  414. this.btnSave.Text = " 新 增";
  415. this.ImageList1.Images.Clear();
  416. this.lstvData.Items.Clear();
  417. this.txtTsc_Name.Focus();
  418. }
  419. /// <summary>
  420. /// 根目录
  421. /// </summary>
  422. private string PPath = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.SightsDirectoryPath();
  423. ImageList ImageList1 = new ImageList();
  424. void GetPhotoData(string StrStyleName)
  425. {
  426. if (!string.IsNullOrEmpty(StrStyleName))
  427. {
  428. this.ImageList1.Images.Clear();
  429. this.lstvData.Items.Clear();
  430. string StrPath = PPath + "\\Small";
  431. if (System.IO.Directory.Exists(StrPath))
  432. {
  433. string[] fileNames = Directory.GetFiles(StrPath);
  434. for (int i = 0; i < fileNames.Length; i++)
  435. {
  436. string[] StrPhotoNameArray = System.IO.Path.GetFileNameWithoutExtension(fileNames[i].Trim()).Split('_');
  437. if (StrPhotoNameArray[0].Trim() == StrStyleName.Trim() || StrStyleName.Trim() == "全部")
  438. {
  439. Image img = Image.FromStream(new MemoryStream(System.IO.File.ReadAllBytes(fileNames[i].Trim())));
  440. string StrPhotoName = System.IO.Path.GetFileNameWithoutExtension(fileNames[i].Trim());
  441. this.ImageList1.Images.Add(StrPhotoName, img);
  442. ListViewItem lvi = new ListViewItem();
  443. lvi.ImageKey = StrPhotoName;
  444. lvi.Text = StrPhotoNameArray[0].Trim() + "_" + StrPhotoNameArray[1].Trim();
  445. lvi.Tag = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.EncryptDES(fileNames[i].Trim().Replace("_Small_", "_Original_").Replace("Small\\", "")) + "_" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.EncryptDES(fileNames[i].Trim());//小图路径
  446. lvi.ToolTipText = lvi.Text;
  447. this.lstvData.Items.Add(lvi);
  448. }
  449. }
  450. }
  451. }
  452. }
  453. char[] StrListChar = ",./;'*-+`~!#$%^&<>?|:".ToCharArray();
  454. /// <summary>
  455. /// 上传相片
  456. /// </summary>
  457. /// <param name="sender"></param>
  458. /// <param name="e"></param>
  459. void btnBrowse_Click(object sender, EventArgs e)
  460. {
  461. try
  462. {
  463. if (this.txtTsc_Name.Tag == null)
  464. { MessageBoxCustom.Show("景点:" + this.txtTsc_Name.Text.Trim() + " 尚未保存,不能上传相片!"); return; }
  465. if (string.IsNullOrEmpty(this.txtTsc_Name.Text) || this.txtTsc_Name.Text.Trim() == "全部")
  466. { MessageBoxCustom.Show("请选择当前景点!"); return; }
  467. OpenFileDialog openFileDialog1 = new OpenFileDialog();
  468. openFileDialog1.FileName = "";
  469. string[] SplitArray = sgbll.GetSystemConfigure("Sconfig_Value", "ImageType").Tables[0].Rows[0]["Sconfig_Value"].ToString().Trim().Split('|');
  470. string SplitStr = "图片文件|";
  471. for (int i = 0; i < SplitArray.Length; i++)
  472. {
  473. if (i > 0)
  474. { SplitStr += ";" + "*" + SplitArray[i].Trim(); }
  475. else
  476. { SplitStr += "*" + SplitArray[i].Trim(); }
  477. }
  478. openFileDialog1.Filter = SplitStr;
  479. openFileDialog1.Multiselect = true;
  480. openFileDialog1.FilterIndex = 2;
  481. if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
  482. {
  483. string[] FileNames = openFileDialog1.FileNames;
  484. string StrPhotoName = this.txtTsc_Name.Text.Trim();
  485. if (FileNames.Length > 20)
  486. { MessageBoxCustom.Show("每个景点上传相片最多不能超过20张"); return; }
  487. if (FileNames.Length + this.lstvData.Items.Count > 20)
  488. { MessageBoxCustom.Show("每个景点上传相片最多不能超过20张"); return; }
  489. for (int i = 0; i < FileNames.Length; i++)
  490. {
  491. string StrFileNameName = System.IO.Path.GetFileNameWithoutExtension(FileNames[i].Trim());
  492. for (int j = 0; j < this.StrListChar.Length; j++)
  493. {
  494. if (StrFileNameName.Trim().Contains(this.StrListChar[j].ToString().Trim()))
  495. { MessageBoxCustom.Show("要上传的相片‘" + StrFileNameName + "’中不能含有非法字符‘" + this.StrListChar[j].ToString().Trim() + "’"); return; }
  496. }
  497. }
  498. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  499. {
  500. try
  501. {
  502. backgroundWorker.ReportProgress(0, "正在上传,请稍等...");
  503. for (int i = 0; i < FileNames.Length; i++)
  504. {
  505. string StrGuid = LYFZ.WinAPI.CustomPublicMethod.GenerateId().ToString();
  506. if (!System.IO.Directory.Exists(PPath))
  507. {
  508. try
  509. { System.IO.Directory.CreateDirectory(PPath); }
  510. catch (Exception ex)
  511. { MessageBoxCustom.Show(ex.Message); return; }
  512. }
  513. string StrFileNameName = System.IO.Path.GetFileNameWithoutExtension(FileNames[i].Trim());
  514. string StrBigPicture = PPath + "\\" + StrPhotoName + "_" + StrFileNameName + "_Original_" + StrGuid + ".jpg";
  515. string StrSmallMapPath = PPath + "\\" + "Small";
  516. if (!System.IO.Directory.Exists(StrSmallMapPath))
  517. {
  518. try
  519. { System.IO.Directory.CreateDirectory(StrSmallMapPath); }
  520. catch (Exception ex)
  521. { MessageBoxCustom.Show(ex.Message); return; }
  522. }
  523. StrSmallMapPath += "\\" + StrPhotoName + "_" + StrFileNameName + "_Small_" + StrGuid + ".jpg";
  524. //LYFZ.BLL.SelectPhotoHandling.SaveIamge(new Bitmap(Image.FromFile(FileNames[i].Trim())), StrBigPicture);
  525. LYFZ.BLL.SelectPhotoHandling.SaveIamge(LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(FileNames[i].Trim(), 1920, 1080), StrBigPicture);
  526. LYFZ.BLL.SelectPhotoHandling.SaveIamge(LYFZ.BLL.SelectPhotoHandling.GeneratePreviewBitmap(FileNames[i].Trim(), 600, 400), StrSmallMapPath);
  527. }
  528. }
  529. catch (Exception ex)
  530. { MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
  531. });
  532. this.GetPhotoData(this.txtTsc_Name.Text.Trim());
  533. }
  534. }
  535. catch { }
  536. }
  537. /// <summary>
  538. /// 删除相片
  539. /// </summary>
  540. /// <param name="sender"></param>
  541. /// <param name="e"></param>
  542. void btnDeletePhoto_Click(object sender, EventArgs e)
  543. {
  544. List<ListViewItem> delList = new List<ListViewItem>();
  545. List<string> StrSelectPathList = new List<string>();
  546. for (int i = 0; i < this.lstvData.SelectedItems.Count; i++)
  547. {
  548. delList.Add(this.lstvData.SelectedItems[i]);
  549. StrSelectPathList.Add(this.lstvData.SelectedItems[i].ImageKey.ToString().Trim() + ".jpg");
  550. }
  551. if (MessageBoxCustom.Show("您确定要删除所选择的相片吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  552. { return; }
  553. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  554. {
  555. for (int i = 0; i < StrSelectPathList.Count; i++)
  556. {
  557. string StrBigPicture = PPath + "\\" + StrSelectPathList[i].Trim();
  558. if (File.Exists(StrBigPicture))
  559. {
  560. backgroundWorker.ReportProgress(0, "正在删除大图...");
  561. File.Delete(StrBigPicture);
  562. }
  563. string StrSmallMapPath = PPath + "\\" + "Small" + "\\" + StrSelectPathList[i].Trim();
  564. if (File.Exists(StrSmallMapPath))
  565. {
  566. backgroundWorker.ReportProgress(0, "正在删除小图...");
  567. File.Delete(StrSmallMapPath);
  568. }
  569. }
  570. try
  571. {
  572. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  573. {
  574. for (int i = 0; i < delList.Count; i++)
  575. { this.lstvData.Items.Remove(delList[i]); }
  576. }));
  577. }
  578. catch
  579. { }
  580. });
  581. }
  582. /// <summary>
  583. /// 双击查看
  584. /// </summary>
  585. /// <param name="sender"></param>
  586. /// <param name="e"></param>
  587. void lstvData_MouseDoubleClick(object sender, MouseEventArgs e)
  588. {
  589. if (lstvData.SelectedItems != null && lstvData.SelectedItems.Count > 0)
  590. {
  591. string[] StrArray = lstvData.SelectedItems[0].Tag.ToString().Trim().Split('_');
  592. Image img = Image.FromStream(new MemoryStream(System.IO.File.ReadAllBytes(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DecryptDES(StrArray[1].Trim()))));
  593. LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic frm = new InitialSet.Product.FrmProductPic();
  594. frm.FrmImage = img;
  595. frm.WindowState = FormWindowState.Maximized;
  596. frm.ShowDialog();
  597. }
  598. }
  599. /// <summary>
  600. /// 新增次数
  601. /// </summary>
  602. /// <param name="sender"></param>
  603. /// <param name="e"></param>
  604. protected override void btnAdd2_Click(object sender, EventArgs e)
  605. { this.BindClear2(); }
  606. /// <summary>
  607. /// 清空
  608. /// </summary>
  609. public void BindClear2()
  610. {
  611. this.txtTsc_Name2.Text = "";
  612. this.txtTsc_Name2.Tag = null;
  613. this.txtTsc_Remark2.Text = "";
  614. this.cmbTsc_Rating2.SelectedItem = null;
  615. this.cmbTcs_Category2.Text = "";
  616. this.cmbtreevIsDisable2.TagFindText("0");
  617. this.btnSave2.Text = " 新 增";
  618. this.txtTsc_Name2.Focus();
  619. }
  620. /// <summary>
  621. /// 显示控件单击事件
  622. /// </summary>
  623. /// <param name="sender"></param>
  624. /// <param name="e"></param>
  625. protected override void dgv2_Click(object sender, EventArgs e)
  626. {
  627. try
  628. {
  629. if (this.dgv2.SelectedRows.Count > 0)
  630. {
  631. //更新赋值
  632. string ID = this.dgv2.CurrentRow.Cells["ID2"].Value.ToString();
  633. DataTable dt = tsbll.GetList("ID=" + ID + "").Tables[0];
  634. this.txtTsc_Name2.Text = dt.Rows[0]["Tsc_Name"].ToString();
  635. this.txtTsc_Name2.Tag = ID;
  636. this.cmbtreevIsDisable2.TagFindText(dt.Rows[0]["Tsc_IsDisable"].ToString().Trim());
  637. this.txtTsc_Remark2.Text = dt.Rows[0]["Tsc_Remark"].ToString();
  638. this.cmbTsc_Rating2.SelectedItem = ListItem.ValueFindByText(this.cmbTsc_Rating2, dt.Rows[0]["Tsc_Rating"].ToString());
  639. if (Convert.ToInt32(dt.Rows[0]["Tcs_Category"]) == 0)
  640. { this.cmbTcs_Category2.Text = "内景"; }
  641. else
  642. { this.cmbTcs_Category2.Text = "外景"; }
  643. this.btnSave2.Text = " 修 改";
  644. // 更新商品权限
  645. this.btnSave2.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.AttractionsCompetence, CustomAttributes.OperatingAuthority.Update);
  646. }
  647. }
  648. catch (Exception ex)
  649. { MessageBoxCustom.Show(ex.Message); }
  650. }
  651. /// <summary>
  652. /// 关闭
  653. /// </summary>
  654. /// <param name="sender"></param>
  655. /// <param name="e"></param>
  656. protected override void btnClose2_Click(object sender, EventArgs e)
  657. { this.Close(); }
  658. /// <summary>
  659. /// 删除
  660. /// </summary>
  661. /// <param name="sender"></param>
  662. /// <param name="e"></param>
  663. protected override void btnDelete2_Click(object sender, EventArgs e)
  664. {
  665. if (this.dgv2.SelectedRows.Count == 0)
  666. { MessageBoxCustom.Show("请选中你要删除的数据!"); return; }
  667. //if (Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value) == 1)
  668. //{ MessageBoxCustom.Show("此景点不能删除!"); return; }
  669. int id = Convert.ToInt32(this.dgv2.CurrentRow.Cells["ID2"].Value);
  670. DataTable dt = orbll.GetView_Custom("tb_ErpTheScenery", StrWhere: "ID = '" + id + "'", ShowColumnName: "Tsc_Name").Tables[0];
  671. if (dt.Rows.Count > 0)
  672. {
  673. DataTable tbl = orbll.GetView_Custom("tb_ErpOrdersPhotography", StrWhere: "Ordpg_Sights = '" + dt.Rows[0]["Tsc_Name"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
  674. if (tbl.Rows.Count > 0)
  675. { MessageBoxCustom.Show("此景点已有订单选中,不能删除!"); return; }
  676. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  677. {
  678. if (tsbll.Delete(id) == true)
  679. {
  680. string logsContent = "删除次数名称:" + txtTsc_Name2.Text.Trim();
  681. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除景点, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  682. MessageBoxCustom.Show("删除成功!");
  683. this.BindClear2();
  684. }
  685. else
  686. { MessageBoxCustom.Show("删除失败!"); }
  687. this.GetAttractionsCs();
  688. }
  689. }
  690. }
  691. /// <summary>
  692. /// 保存
  693. /// </summary>
  694. /// <param name="sender"></param>
  695. /// <param name="e"></param>
  696. protected override void btnSave2_Click(object sender, EventArgs e)
  697. {
  698. #region 判断资料不能为空
  699. if (string.IsNullOrEmpty(this.txtTsc_Name2.Text.Trim()))
  700. { MessageBoxCustom.Show("次数名称不能为空!"); this.txtTsc_Name2.Focus(); return; }
  701. if (string.IsNullOrEmpty(this.cmbTsc_Rating2.Text.Trim()))
  702. { MessageBoxCustom.Show("次数等级不能为空!"); return; }
  703. if (string.IsNullOrEmpty(this.cmbTcs_Category2.Text.Trim()))
  704. { MessageBoxCustom.Show("次数所属类型不能为空!"); return; }
  705. if (string.IsNullOrEmpty(this.cmbtreevIsDisable2.Text.Trim()))
  706. { MessageBoxCustom.Show("次数是否启用不能为空!"); return; }
  707. if (this.txtTsc_Name2.Text.Trim().Length > 20)
  708. { MessageBoxCustom.Show("次数名称长度不能超过20字!"); return; }
  709. #endregion
  710. #region 增加、修改
  711. try
  712. {
  713. if (this.txtTsc_Name2.Tag == null)
  714. {
  715. #region 判断景点名称是否存在
  716. //if (tsbll.Exists("Tsc_Name", this.txtTsc_Name2.Text) == true)
  717. if (tsbll.GetList("Tsc_Name = '" + this.txtTsc_Name2.Text.Trim() + "' and Tsc_Type = '1'").Tables[0].Rows.Count > 0)
  718. {
  719. MessageBoxCustom.Show("次数名称已经存在!");
  720. this.txtTsc_Name2.Text = "";
  721. this.txtTsc_Name2.Focus();
  722. return;
  723. }
  724. #endregion
  725. LYFZ.Model.Model_ErpTheScenery model = new Model.Model_ErpTheScenery();
  726. model.Tsc_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  727. model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name2.Text.Trim());
  728. model.Tsc_Type = "1";
  729. if (cmbTcs_Category2.Text == "内景")
  730. { model.Tcs_Category = 0; }
  731. else
  732. { model.Tcs_Category = 1; }
  733. model.Tsc_PackagesMainClass = this.StrPackagesType;
  734. model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating2.SelectedItem).StrValue.ToString().Trim();
  735. model.Tsc_IsDisable = this.cmbtreevIsDisable2.Tag.ToString().Trim();
  736. model.Tsc_Remark = txtTsc_Remark2.Text;
  737. model.Tsc_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  738. model.Tsc_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  739. if (!tsbll.Add(model))
  740. { MessageBoxCustom.Show("保存失败!"); return; }
  741. }
  742. else
  743. {
  744. #region 判断景点名称是否存在
  745. if (!string.IsNullOrEmpty(txtTsc_Name2.Text))
  746. {
  747. DataTable dt = tsbll.GetList("ID=" + dgv2.CurrentRow.Cells["ID2"].Value.ToString() + "", "ID desc").Tables[0];
  748. string Tsc_Name = dt.Rows[0]["Tsc_Name"].ToString();
  749. if (Tsc_Name != txtTsc_Name2.Text)
  750. {
  751. dt = tsbll.GetList("Tsc_Name='" + txtTsc_Name2.Text + "'").Tables[0];
  752. if (dt.Rows.Count > 0)
  753. { MessageBoxCustom.Show("景点名称已经存在!"); return; }
  754. }
  755. }
  756. #endregion
  757. LYFZ.Model.Model_ErpTheScenery model = tsbll.GetModel(Convert.ToInt32(this.txtTsc_Name2.Tag));
  758. model.Tsc_Name = LYFZ.BLL.OtherCommonModel.ClearSpecialCharacter(this.txtTsc_Name2.Text.Trim());
  759. model.Tsc_Rating = ((ListItem)this.cmbTsc_Rating2.SelectedItem).StrValue.ToString().Trim();
  760. model.Tsc_IsDisable = this.cmbtreevIsDisable2.Tag.ToString().Trim();
  761. model.Tsc_Remark = txtTsc_Remark2.Text;
  762. if (cmbTcs_Category2.Text == "内景")
  763. { model.Tcs_Category = 0; }
  764. else
  765. { model.Tcs_Category = 1; }
  766. model.Tsc_UpdateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  767. model.Tsc_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  768. if (!tsbll.Update(model))
  769. { MessageBoxCustom.Show("保存失败!"); return; }
  770. }
  771. this.GetAttractionsCs();
  772. this.BindClear2();
  773. MessageBoxCustom.Show("保存成功!");
  774. }
  775. catch (Exception ex)
  776. { MessageBoxCustom.Show(ex.Message); }
  777. #endregion
  778. }
  779. }
  780. }