FrmPurchaseOrder.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. namespace LYFZ.Software.MainBusiness.InventoryManagement
  11. {
  12. public partial class FrmPurchaseOrder : LYFZ.Software.UI.InventoryManagement.FrmPurchaseOrder
  13. {
  14. public FrmPurchaseOrder()
  15. {
  16. }
  17. private DataTable tbl_View = new DataTable();
  18. #region 加载
  19. protected override void FrmPurchaseOrder_Shown(object sender, EventArgs e)
  20. {
  21. try
  22. {
  23. bind();
  24. radKsq_Click(sender, e);
  25. }
  26. catch (Exception ex)
  27. {
  28. MessageBoxCustom.Show(ex.Message);
  29. }
  30. }
  31. #region 获取报警商品
  32. /// <summary>
  33. /// 获取报警商品
  34. /// </summary>
  35. public void bind()
  36. {
  37. dgv1.Rows.Clear();
  38. #region 获取报警商品
  39. LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
  40. DataTable dt = Productbll.View_tb_ErpProduct("Prod_Quantity<=Prod_AlarmQuantity and Prod_IsEnabled='1'").Tables[0];
  41. if (dt.Rows.Count > 0)
  42. {
  43. for (int t = 0; t < dt.Rows.Count; t++)
  44. {
  45. LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
  46. DataTable dal = new DataTable();
  47. dal = PurchaseProductBll.GetList("Ppt_ProductNumber='" + dt.Rows[t]["Prod_Number"].ToString().Trim() + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3') ").Tables[0];
  48. DataGridViewRow dgvr = new DataGridViewRow();
  49. DataGridViewCell cell = null;
  50. cell = new DataGridViewTextBoxCell();
  51. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  52. dgvr.Cells.Add(cell);
  53. cell = new DataGridViewTextBoxCell();
  54. cell.Value = dt.Rows[t]["Prod_Name"].ToString().Trim();
  55. dgvr.Cells.Add(cell);
  56. cell = new DataGridViewTextBoxCell();
  57. if (dal.Rows.Count > 0)
  58. {
  59. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "0" || dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
  60. {
  61. dal = PurchaseProductBll.GetList("Ppt_ProductNumber='" + dt.Rows[t]["Prod_Number"].ToString() + "'").Tables[0];
  62. cell.Value = dal.Rows[0]["Ppt_PurchaseQuantity"].ToString();
  63. }
  64. }
  65. else { cell.Value = "0"; }
  66. //dt.Rows[t]["Prod_Quantity"].ToString().Trim();
  67. dgvr.Cells.Add(cell);
  68. cell = new DataGridViewTextBoxCell();
  69. cell.Value = dt.Rows[t]["Prod_ClassName"].ToString().Trim();
  70. dgvr.Cells.Add(cell);
  71. cell = new DataGridViewTextBoxCell();
  72. cell.Value = dt.Rows[t]["Prod_AlarmQuantity"].ToString().Trim();
  73. dgvr.Cells.Add(cell);
  74. cell = new DataGridViewTextBoxCell();
  75. cell.Value = dt.Rows[t]["Prod_PreSaleQuantity"].ToString().Trim();
  76. dgvr.Cells.Add(cell);
  77. cell = new DataGridViewTextBoxCell();
  78. cell.Value = dt.Rows[t]["Prod_Class"].ToString().Trim();
  79. dgvr.Cells.Add(cell);
  80. cell = new DataGridViewTextBoxCell();
  81. cell.Value = dt.Rows[t]["Prod_Number"].ToString().Trim();
  82. dgvr.Cells.Add(cell);
  83. cell = new DataGridViewTextBoxCell();
  84. if (dal.Rows.Count > 0)
  85. {
  86. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "0")
  87. {
  88. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
  89. }
  90. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "1")
  91. {
  92. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString();
  93. }
  94. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "2")
  95. {
  96. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString();
  97. }
  98. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
  99. {
  100. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
  101. }
  102. }
  103. else { cell.Value = "可申请"; }
  104. dgvr.Cells.Add(cell);
  105. this.dgv1.Rows.Add(dgvr);
  106. }
  107. for (int i = 0; i < dgv1.Rows.Count; i++)
  108. {
  109. string Ppt_PurchaseStatus = dgv1.Rows[i].Cells["Status"].Value.ToString();
  110. if (Ppt_PurchaseStatus.ToString() == LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString() || Ppt_PurchaseStatus.ToString() == LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString())
  111. {
  112. this.dgv1.Rows[i].DefaultCellStyle.ForeColor = Color.YellowGreen;
  113. }
  114. }
  115. lblcount.Text = dgv1.Rows.Count.ToString();
  116. dgv1.ClearSelection();
  117. }
  118. #endregion
  119. tbl_View = GetDgvToTable(dgv1);
  120. }
  121. #endregion
  122. #region 获取已申请商品
  123. /// <summary>
  124. /// 获取已申请商品
  125. /// </summary>
  126. public void GetYsq()
  127. {
  128. dgv1.Rows.Clear();
  129. #region 获取采购商品表
  130. LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductbll = new BLL.BLL_ErpPurchaseProduct();
  131. DataTable dt = PurchaseProductbll.GetList("Ppt_PurchaseStatus='3' or Ppt_PurchaseStatus='0'").Tables[0];
  132. if (dt.Rows.Count > 0)
  133. {
  134. for (int t = 0; t < dt.Rows.Count; t++)
  135. {
  136. DataGridViewRow dgvr = new DataGridViewRow();
  137. DataGridViewCell cell = null;
  138. cell = new DataGridViewTextBoxCell();
  139. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  140. dgvr.Cells.Add(cell);
  141. cell = new DataGridViewTextBoxCell();
  142. cell.Value = PurchaseProductbll.GetProductName(dt.Rows[t]["Ppt_ProductNumber"].ToString().Trim());
  143. dgvr.Cells.Add(cell);
  144. cell = new DataGridViewTextBoxCell();
  145. cell.Value = dt.Rows[t]["Ppt_PurchaseQuantity"].ToString().Trim();
  146. dgvr.Cells.Add(cell);
  147. cell = new DataGridViewTextBoxCell();
  148. cell.Value = PurchaseProductbll.GetProductCategory(dt.Rows[t]["Ppt_ProductCategory"].ToString().Trim());
  149. dgvr.Cells.Add(cell);
  150. cell = new DataGridViewTextBoxCell();
  151. cell.Value = "";
  152. dgvr.Cells.Add(cell);
  153. cell = new DataGridViewTextBoxCell();
  154. cell.Value = "";
  155. dgvr.Cells.Add(cell);
  156. cell = new DataGridViewTextBoxCell();
  157. cell.Value = dt.Rows[t]["Ppt_ProductCategory"].ToString().Trim();
  158. dgvr.Cells.Add(cell);
  159. cell = new DataGridViewTextBoxCell();
  160. cell.Value = dt.Rows[t]["Ppt_ProductNumber"].ToString().Trim();
  161. dgvr.Cells.Add(cell);
  162. #region 采购状态
  163. cell = new DataGridViewTextBoxCell();
  164. if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "0")
  165. {
  166. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
  167. }
  168. if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "1")
  169. {
  170. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString();
  171. }
  172. if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "2")
  173. {
  174. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString();
  175. }
  176. if (dt.Rows[t]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
  177. {
  178. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
  179. }
  180. dgvr.Cells.Add(cell);
  181. #endregion
  182. this.dgv1.Rows.Add(dgvr);
  183. }
  184. #region 变色
  185. for (int i = 0; i < dgv1.Rows.Count; i++)
  186. {
  187. string Ppt_PurchaseStatus = dgv1.Rows[i].Cells["Status"].Value.ToString();
  188. if (Ppt_PurchaseStatus.ToString() == LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString() || Ppt_PurchaseStatus.ToString() == LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString())
  189. {
  190. this.dgv1.Rows[i].DefaultCellStyle.ForeColor = Color.YellowGreen;
  191. }
  192. }
  193. #endregion
  194. dgv1.ClearSelection();
  195. }
  196. #endregion
  197. lblcount.Text = dgv1.Rows.Count.ToString();
  198. }
  199. #endregion
  200. #endregion
  201. #region 只能输入数字
  202. protected override void dgv1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  203. {
  204. try
  205. {
  206. if (dgv1.Rows.Count > 0)
  207. {
  208. if (Command.Command_Validate.IsNumber(dgv1.CurrentRow.Cells["Prod_Quantity"].Value.ToString()) == false)
  209. {
  210. MessageBoxCustom.Show("只能输入纯数字!");
  211. //int id = Convert.ToInt32(dgv1.CurrentRow.Cells["ID"].Value);
  212. //LYFZ.BLL.BLL_ErpProduct bll = new BLL.BLL_ErpProduct();
  213. dgv1.CurrentRow.Cells["Prod_Quantity"].Value = "0";//bll.GetList("ID=" + id + "").Tables[0].Rows[0]["Prod_Quantity"].ToString();
  214. return;
  215. }
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. MessageBoxCustom.Show(ex.Message);
  221. }
  222. }
  223. #endregion
  224. #region 选择商品
  225. protected override void btnProductSelection_Click(object sender, EventArgs e)
  226. {
  227. try
  228. {
  229. LYFZ.Software.MainBusiness.InventoryManagement.FrmProductSearch set = new FrmProductSearch();
  230. set.ShowDialog();
  231. if (set.ListArray.Count > 0)
  232. {
  233. for (int y = 0; y < set.ListArray.Count; y++)
  234. {
  235. for (int u = 0; u < dgv1.Rows.Count; u++)
  236. {
  237. string sp=set.ListArray[y].ToString();
  238. if (sp.ToString() == dgv1.Rows[u].Cells["Prod_Number"].Value.ToString())
  239. {
  240. MessageBoxCustom.Show("【"+dgv1.Rows[u].Cells["Ir_ProductName"].Value.ToString()+ "】"+ " 商品已经存在列表,不能增加!");
  241. return;
  242. }
  243. }
  244. }
  245. for (int i = 0; i < set.ListArray.Count; i++)
  246. {
  247. #region 获取所有商品
  248. LYFZ.BLL.BLL_ErpProduct Productbll = new BLL.BLL_ErpProduct();
  249. DataTable dt = Productbll.View_tb_ErpProduct(" Prod_Number='" + set.ListArray[i] + "' ").Tables[0];
  250. if (dt.Rows.Count > 0)
  251. {
  252. for (int t = 0; t < dt.Rows.Count; t++)
  253. {
  254. DataGridViewRow dgvr = new DataGridViewRow();
  255. DataGridViewCell cell = null;
  256. cell = new DataGridViewTextBoxCell();
  257. cell.Value = dt.Rows[t]["ID"].ToString().Trim();
  258. dgvr.Cells.Add(cell);
  259. cell = new DataGridViewTextBoxCell();
  260. cell.Value = dt.Rows[t]["Prod_Name"].ToString().Trim();
  261. dgvr.Cells.Add(cell);
  262. cell = new DataGridViewTextBoxCell();
  263. cell.Value = "0"; //dt.Rows[t]["Prod_Quantity"].ToString().Trim();
  264. dgvr.Cells.Add(cell);
  265. cell = new DataGridViewTextBoxCell();
  266. cell.Value = dt.Rows[t]["Prod_ClassName"].ToString().Trim();
  267. dgvr.Cells.Add(cell);
  268. cell = new DataGridViewTextBoxCell();
  269. cell.Value = dt.Rows[t]["Prod_AlarmQuantity"].ToString().Trim();
  270. dgvr.Cells.Add(cell);
  271. cell = new DataGridViewTextBoxCell();
  272. cell.Value = dt.Rows[t]["Prod_PreSaleQuantity"].ToString().Trim();
  273. dgvr.Cells.Add(cell);
  274. cell = new DataGridViewTextBoxCell();
  275. cell.Value = dt.Rows[t]["Prod_Class"].ToString().Trim();
  276. dgvr.Cells.Add(cell);
  277. cell = new DataGridViewTextBoxCell();
  278. cell.Value = dt.Rows[t]["Prod_Number"].ToString().Trim();
  279. dgvr.Cells.Add(cell);
  280. cell = new DataGridViewTextBoxCell();
  281. LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
  282. DataTable dal = new DataTable();
  283. dal = PurchaseProductBll.GetList("Ppt_ProductNumber='" + dt.Rows[t]["Prod_Number"].ToString().Trim() + "' and (Ppt_PurchaseStatus='0' or Ppt_PurchaseStatus='3') ").Tables[0];
  284. if (dal.Rows.Count > 0)
  285. {
  286. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "0")
  287. {
  288. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString();
  289. }
  290. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "1")
  291. {
  292. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购完成.ToString();
  293. }
  294. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "2")
  295. {
  296. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.采购取消.ToString();
  297. }
  298. if (dal.Rows[0]["Ppt_PurchaseStatus"].ToString().Trim() == "3")
  299. {
  300. cell.Value = LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString();
  301. }
  302. }
  303. else { cell.Value = "可申请"; }
  304. dgvr.Cells.Add(cell);
  305. this.dgv1.Rows.Add(dgvr);
  306. }
  307. lblcount.Text = dgv1.Rows.Count.ToString();
  308. dgv1.ClearSelection();
  309. }
  310. #endregion
  311. }
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. MessageBoxCustom.Show(ex.Message);
  317. }
  318. }
  319. #endregion
  320. #region 删除
  321. protected override void btndelete_Click(object sender, EventArgs e)
  322. {
  323. if (dgv1.SelectedCells.Count == 0)
  324. {
  325. MessageBoxCustom.Show("请选择你要删除的数据!");
  326. return;
  327. }
  328. string Status = dgv1.CurrentRow.Cells["Status"].Value.ToString();
  329. if (Status.ToString() == "可申请")
  330. {
  331. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  332. {
  333. dgv1.Rows.RemoveAt(dgv1.CurrentRow.Index);
  334. lblcount.Text = dgv1.Rows.Count.ToString();
  335. }
  336. }
  337. else { MessageBoxCustom.Show("此商品正在 " + Status + " 不能删除!"); }
  338. }
  339. #endregion
  340. #region 关闭
  341. protected override void btnClose_Click(object sender, EventArgs e)
  342. {
  343. this.Close();
  344. }
  345. #endregion
  346. #region 采购
  347. protected override void btnSave_Click(object sender, EventArgs e)
  348. {
  349. try
  350. {
  351. #region 检查商品是否可以申请采购
  352. for (int i = 0; i < dgv1.Rows.Count; i++)
  353. {
  354. string Ir_ProductName = dgv1.Rows[i].Cells["Ir_ProductName"].Value.ToString();
  355. string Status = dgv1.Rows[i].Cells["Status"].Value.ToString();
  356. if (Status.ToString() == LYFZ.EnumPublic.Ppt_PurchaseStatus.采购中.ToString() || Status.ToString() == LYFZ.EnumPublic.Ppt_PurchaseStatus.申请中.ToString())
  357. {
  358. MessageBoxCustom.Show(Ir_ProductName + " 正在" + Status + "不能采购!");
  359. return;
  360. }
  361. }
  362. #endregion
  363. #region 增加采购单
  364. if (dgv1.Rows.Count > 0)
  365. {
  366. if (MessageBoxCustom.Show("你确定采购列表中的商品吗?", "增加提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  367. {
  368. #region 增加采购订单表
  369. LYFZ.Model.Model_ErpPurchaseOrder PurchaseOrderModel = new Model.Model_ErpPurchaseOrder();
  370. LYFZ.BLL.BLL_ErpPurchaseOrder PurchaseOrderBll = new BLL.BLL_ErpPurchaseOrder();
  371. Random action = new Random();
  372. PurchaseOrderModel.Pord_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  373. PurchaseOrderModel.Pord_PurchaseNumber = "St" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmss") + action.Next(100, 1000);
  374. PurchaseOrderModel.Pord_PurchaseName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyy-MM-dd") + " 采购单";
  375. PurchaseOrderModel.Pord_RequisitionName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  376. PurchaseOrderModel.Pord_RequisitionTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  377. PurchaseOrderModel.Pord_ApprovalStatus = "1";
  378. PurchaseOrderModel.Pord_ApprovalName = "";
  379. PurchaseOrderModel.Pord_ApprovalTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  380. PurchaseOrderModel.Pord_ApprovalRemark = "";
  381. PurchaseOrderModel.Pord_PurchaseStatus = "3";
  382. PurchaseOrderBll.Add(PurchaseOrderModel);
  383. #endregion
  384. #region 增加采购商品表
  385. LYFZ.Model.Model_ErpPurchaseProduct PurchaseProductModel = new Model.Model_ErpPurchaseProduct();
  386. LYFZ.BLL.BLL_ErpPurchaseProduct PurchaseProductBll = new BLL.BLL_ErpPurchaseProduct();
  387. for (int i = 0; i < dgv1.Rows.Count; i++)
  388. {
  389. PurchaseProductModel.Ppt_PurchaseNumber = PurchaseOrderModel.Pord_PurchaseNumber;
  390. PurchaseProductModel.Ppt_ProductCategory = dgv1.Rows[i].Cells["Prod_Class"].Value.ToString();
  391. PurchaseProductModel.Ppt_ProductNumber = dgv1.Rows[i].Cells["Prod_Number"].Value.ToString();
  392. PurchaseProductModel.Ppt_PurchaseQuantity = Convert.ToInt32(dgv1.Rows[i].Cells["Prod_Quantity"].Value);
  393. PurchaseProductModel.Ppt_PurchaseVendor = "";
  394. PurchaseProductModel.Ppt_PurchasePrice = 0;
  395. PurchaseProductModel.Ppt_PurchaseStatus = "3";
  396. PurchaseProductModel.Ppt_PurchasePerson = "";
  397. PurchaseProductModel.Ppt_PurchaseTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  398. PurchaseProductModel.Ppt_AcceptanceQuantity = 0;
  399. PurchaseProductModel.Ppt_AcceptanceTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  400. PurchaseProductModel.Ppt_AcceptanceName = "";
  401. PurchaseProductModel.Ppt_StorageStatus = "0";
  402. PurchaseProductModel.Ppt_Remark = "";
  403. PurchaseProductBll.Add(PurchaseProductModel);
  404. }
  405. #endregion
  406. MessageBoxCustom.Show("保存成功!采购单号已生成!");
  407. this.Close();
  408. }
  409. }
  410. else { MessageBoxCustom.Show("列表中商品不能为空!请添加商品!"); }
  411. #endregion
  412. }
  413. catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
  414. }
  415. #endregion
  416. #region C#如何从DataGridView控件数据,转成获取DataTable
  417. public DataTable GetDgvToTable(DataGridView dgv)
  418. {
  419. DataTable dt = new DataTable();
  420. for (int count = 0; count < dgv.Columns.Count; count++)
  421. {
  422. DataColumn dc = new DataColumn(dgv.Columns[count].Name.ToString());
  423. dt.Columns.Add(dc);
  424. }
  425. for (int count = 0; count < dgv.Rows.Count; count++)
  426. {
  427. DataRow dr = dt.NewRow();
  428. for (int countsub = 0; countsub < dgv.Columns.Count; countsub++)
  429. {
  430. dr[countsub] = Convert.ToString(dgv.Rows[count].Cells[countsub].Value);
  431. }
  432. dt.Rows.Add(dr);
  433. }
  434. return dt;
  435. }
  436. #endregion
  437. #region 已申请
  438. protected override void radAll_Click(object sender, EventArgs e)
  439. {
  440. GetYsq();
  441. }
  442. #endregion
  443. #region 可申请
  444. protected override void radKsq_Click(object sender, EventArgs e)
  445. {
  446. dgv1.Rows.Clear();
  447. if (tbl_View.Rows.Count > 0)
  448. {
  449. DataRow[] dtr = tbl_View.Select("Status='可申请'");
  450. #region
  451. for (int i = 0; i < dtr.Length; i++)
  452. {
  453. DataGridViewRow dgvl = new DataGridViewRow();
  454. DataGridViewCell cell = null;
  455. cell = new DataGridViewTextBoxCell();
  456. cell.Value = dtr[i][0].ToString();
  457. dgvl.Cells.Add(cell);
  458. cell = new DataGridViewTextBoxCell();
  459. cell.Value = dtr[i][1].ToString();
  460. dgvl.Cells.Add(cell);
  461. cell = new DataGridViewTextBoxCell();
  462. cell.Value = dtr[i][2].ToString();
  463. dgvl.Cells.Add(cell);
  464. cell = new DataGridViewTextBoxCell();
  465. cell.Value = dtr[i][3].ToString();
  466. dgvl.Cells.Add(cell);
  467. cell = new DataGridViewTextBoxCell();
  468. cell.Value = dtr[i][4].ToString();
  469. dgvl.Cells.Add(cell);
  470. cell = new DataGridViewTextBoxCell();
  471. cell.Value = dtr[i][5].ToString();
  472. dgvl.Cells.Add(cell);
  473. cell = new DataGridViewTextBoxCell();
  474. cell.Value = dtr[i][6].ToString();
  475. dgvl.Cells.Add(cell);
  476. cell = new DataGridViewTextBoxCell();
  477. cell.Value = dtr[i][7].ToString();
  478. dgvl.Cells.Add(cell);
  479. cell = new DataGridViewTextBoxCell();
  480. cell.Value = dtr[i][8].ToString();
  481. dgvl.Cells.Add(cell);
  482. dgv1.Rows.Add(dgvl);
  483. }
  484. #endregion
  485. }
  486. lblcount.Text = dgv1.Rows.Count.ToString();
  487. dgv1.ClearSelection();
  488. }
  489. #endregion
  490. }
  491. }