FrmFundInOutQuery.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Infragistics.Win.UltraWinGrid;
  10. namespace Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIFrm
  11. {
  12. public partial class FrmFundInOutQuery : FrmFundBase
  13. {
  14. public FrmFundInOutQuery()
  15. {
  16. InitializeComponent();
  17. }
  18. private DataSet dsMain = new DataSet();
  19. private DataSet dsDetail = new DataSet();
  20. private string _buyercode = "";
  21. private string _buyercodeNotChooseInfo = "未选择客户名称";
  22. FundBLL.ValueList.PubValueList PubValueList = null;
  23. private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Fund.FundBll fundBll = null;
  24. private string _busiseq = "";
  25. private System.Collections.Hashtable _hsDept = null;
  26. private void FrmFundInOutQuery_Load(object sender, EventArgs e)
  27. {
  28. this.checkBox1.Checked = true;
  29. this.dateTimePicker2.Value = System.DateTime.Now.AddDays(-System.DateTime.Now.Day+1);
  30. fundBll = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Fund.FundBll(this.ob);
  31. PubValueList = new Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.ValueList.PubValueList(this.ob);
  32. dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
  33. new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
  34. this.ultraGrid1.DataSource = dsDetail;
  35. Init();
  36. base.SetGridStyle(ref this.ultraGrid1);
  37. _hsDept = this.GetDeptIdAndSaleArea();
  38. this.ultraGrid1.DisplayLayout.Bands[0].Columns[this.BUSISEQ].Width = 110;
  39. }
  40. private void SetForeColor()
  41. {
  42. try
  43. {
  44. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrs in this.ultraGrid1.Rows)
  45. {
  46. if (ugrs.Cells[this.ISVALID].Value.ToString() == "0")
  47. ugrs.Appearance.ForeColor = Color.Red;
  48. }
  49. }
  50. catch
  51. { }
  52. }
  53. private void Init()
  54. {
  55. try
  56. {
  57. this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUYERCODE"].ValueList
  58. = PubValueList.GetCustomerInfo();
  59. this.ultraGrid1.DisplayLayout.Bands[0].Columns[this.PREBUYERCODE].ValueList
  60. = PubValueList.GetCustomerInfo();
  61. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ISVALID"].ValueList
  62. = GetIsValid();
  63. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MONEY_DELIVER"].ValueList
  64. = GetMoneyDel();
  65. }
  66. catch
  67. { }
  68. //this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUYERCODE"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always;
  69. //this.ultraGrid1.DisplayLayout.Bands[0].Columns["SECONDACCOUNT"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always;
  70. //this.ultraGrid1.DisplayLayout.Bands[0].Columns["BALANCESUBJECT"].MergedCellStyle = Infragistics.Win.UltraWinGrid.MergedCellStyle.Always;
  71. }
  72. public override void ToolBar_Click(object sender, string ToolbarKey)
  73. {
  74. if (ToolbarKey == "Query")
  75. {
  76. this.Query();
  77. }
  78. if (ToolbarKey == "Close")
  79. {
  80. this.Close();
  81. }
  82. if (ToolbarKey == "Export")
  83. {
  84. Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("回款记录", this.ultraGrid1);
  85. }
  86. if (ToolbarKey == "Affrim")
  87. {
  88. this.Affrim();
  89. }
  90. if (ToolbarKey == "UnAffrim")
  91. {
  92. this.UnAffrim();
  93. }
  94. }
  95. private void UnAffrim()
  96. {
  97. try
  98. {
  99. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  100. if (this.ultraGrid1.Rows.Count == 0)
  101. return;
  102. if (this.ultraGrid1.Rows.Count == 1)
  103. ugr = this.ultraGrid1.Rows[0];
  104. else
  105. ugr = this.ultraGrid1.ActiveRow;
  106. if (ugr == null)
  107. {
  108. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 请选择需要撤销审核的行 ");
  109. return;
  110. }
  111. if (ugr.Cells[this.ISVALID].Value.ToString() == "0")
  112. {
  113. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 未审核状态,不需要撤销 ");
  114. return;
  115. }
  116. string busiseq = ugr.Cells[BUSISEQ].Value.ToString();
  117. string balnacesub = ugr.Cells[BALANCESUBJECT].Value.ToString();
  118. string buyercode = ugr.Cells[BUYERCODE].Value.ToString();
  119. string fundtype = ugr.Cells[FUNDTYPE].Value.ToString();
  120. string billno = "";
  121. double money = -Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[INOUTMONEY].Value);
  122. string import = base.GetUserName();
  123. string importtime = "";
  124. string inouttime = "";
  125. string remark = "";
  126. string orderno = "";
  127. double leavemny = 0;
  128. string seccount = ugr.Cells[SECONDACCOUNT].Value.ToString();
  129. string err = "";
  130. _busiseq = busiseq;
  131. base.GetIInstanceCustInout().UnAffrimFundRecord(busiseq, balnacesub, buyercode, fundtype, billno,
  132. money, import, importtime, inouttime, remark,orderno, leavemny, seccount, out err);
  133. if (err.Length == 0)
  134. {
  135. this.Query();
  136. // this.QueryInOutDetail();
  137. Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess);
  138. }
  139. else
  140. {
  141. // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err);
  142. }
  143. }
  144. catch
  145. { }
  146. }
  147. private void Affrim()
  148. {
  149. try
  150. {
  151. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  152. if (this.ultraGrid1.Rows.Count == 0)
  153. return;
  154. if (this.ultraGrid1.Rows.Count == 1)
  155. ugr = this.ultraGrid1.Rows[0];
  156. else
  157. ugr = this.ultraGrid1.ActiveRow;
  158. if (ugr == null)
  159. {
  160. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 请选择需要确认的行 ");
  161. return;
  162. }
  163. if (ugr.Cells[this.ISVALID].Value.ToString() == "1")
  164. {
  165. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 已经确认,不能重复确认 ");
  166. return;
  167. }
  168. string busiseq = ugr.Cells[BUSISEQ].Value.ToString();
  169. string balnacesub = ugr.Cells[BALANCESUBJECT].Value.ToString();
  170. string buyercode = ugr.Cells[BUYERCODE].Value.ToString();
  171. string fundtype = ugr.Cells[FUNDTYPE].Value.ToString();
  172. string billno = "";
  173. double money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[INOUTMONEY].Value);
  174. string import = base.GetUserName();
  175. string importtime = "";
  176. string inouttime = "";
  177. string remark = "";
  178. string orderno = "";
  179. double leavemny = 0;
  180. string seccount = ugr.Cells[SECONDACCOUNT].Value.ToString();
  181. string err = "";
  182. _busiseq = busiseq;
  183. base.GetIInstanceCustInout().AffrimFundRecord(busiseq, balnacesub, buyercode, fundtype, billno,
  184. money, import, importtime, inouttime, remark, orderno, leavemny, seccount, out err);
  185. if (err.Length == 0)
  186. {
  187. this.Query();
  188. // this.QueryInOutDetail();
  189. Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess);
  190. }
  191. else
  192. {
  193. // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err);
  194. }
  195. }
  196. catch
  197. { }
  198. }
  199. private void Query()
  200. {
  201. string balanceSubject = base.GetSaleOrgDesc();
  202. string buyercode = this._buyercode;
  203. Boolean isOpenFilter = true;
  204. string begintime = this.dateTimePicker2.Value.ToString(base._dateTimeFormatYyyyMmdd);
  205. string endtime = this.dateTimePicker3.Value.ToString(base._dateTimeFormatYyyyMmdd);
  206. if (!this.checkBox1.Checked)
  207. {
  208. begintime = System.DateTime.Now.AddYears(-100).ToString(base._dateTimeFormatYyyyMmdd);
  209. endtime = System.DateTime.Now.AddYears(2).ToString(base._dateTimeFormatYyyyMmdd);
  210. }
  211. DataSet ds = null;
  212. if (buyercode.Length > 0)
  213. {
  214. ds = base.GetIInstanceCustInout().GetSelFundCustFundInOutByBalanceAndBuyercodeAndTime
  215. (balanceSubject, buyercode, begintime, endtime);
  216. }
  217. else
  218. {
  219. ds = base.GetIInstanceCustInout().GetSelFundCustFundInOutByBalanceAndTime(balanceSubject, begintime, endtime);
  220. }
  221. System.Collections.ArrayList list = new System.Collections.ArrayList();
  222. string deptName = "";
  223. try
  224. {
  225. list = (System.Collections.ArrayList)_hsDept[CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid()];
  226. }
  227. catch
  228. {
  229. }
  230. if ( list != null && list.Count > 0)
  231. {
  232. if (this.CustomInfo == "1")
  233. {
  234. object[] obj = list.ToArray();
  235. string[] s = new string[obj.Length];
  236. for (int i = 0; i < s.Length; i++)
  237. {
  238. s[i] = obj[i].ToString();
  239. }
  240. if (isOpenFilter)
  241. {
  242. ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, "SECONDACCOUNT", s);
  243. }
  244. }
  245. }
  246. DataSet dsgm = new DataSet();
  247. try
  248. {
  249. if (dsgm.Tables[0].Rows.Count > 0)
  250. {
  251. dsgm.Tables[0].TableName = ds.Tables[0].TableName;
  252. ds.Merge(dsgm);
  253. }
  254. }
  255. catch
  256. {
  257. }
  258. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsDetail, ds);
  259. try
  260. {
  261. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrs in this.ultraGrid1.Rows)
  262. {
  263. if (ugrs.Cells[this.BUSISEQ].Value.ToString() == this._busiseq)
  264. ugrs.Activated = true;
  265. break;
  266. }
  267. }
  268. catch
  269. { }
  270. SetForeColor();
  271. }
  272. private Infragistics.Win.ValueList GetIsValid()
  273. {
  274. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  275. lit.ValueListItems.Add("0", "无效");
  276. lit.ValueListItems.Add("1", "有效");
  277. return lit;
  278. }
  279. private Infragistics.Win.ValueList GetMoneyDel()
  280. {
  281. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  282. lit.ValueListItems.Add("0", "无");
  283. lit.ValueListItems.Add("1", "制造");
  284. lit.ValueListItems.Add("2", "集团");
  285. return lit;
  286. }
  287. private System.Collections.Hashtable GetDeptIdAndSaleArea()
  288. {
  289. System.Collections.Hashtable hs = new System.Collections.Hashtable();
  290. try
  291. {
  292. string sql = " select * from slm_base_sale_area_typ where validflag = '1' ";
  293. DataSet ds = base.ExecuteReader(sql);
  294. if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
  295. {
  296. return hs;
  297. }
  298. System.Collections.ArrayList list = null;
  299. foreach (DataRow dr in ds.Tables[0].Rows)
  300. {
  301. list = new System.Collections.ArrayList();
  302. if (hs.ContainsKey(dr["DEPARTID"].ToString()))
  303. {
  304. list = (System.Collections.ArrayList)hs[dr["DEPARTID"].ToString()];
  305. list.Add(dr["SALE_AREA_DESC"].ToString());
  306. hs.Remove(dr["DEPARTID"].ToString());
  307. hs.Add(dr["DEPARTID"].ToString(), list);
  308. }
  309. else
  310. {
  311. list.Add(dr["SALE_AREA_DESC"].ToString());
  312. hs.Add(dr["DEPARTID"].ToString(), list);
  313. }
  314. }
  315. }
  316. catch
  317. { }
  318. return hs;
  319. }
  320. public string[] GetTbColumn_SEL_FUND_CUST_FUNDINOUT()
  321. {
  322. return new string[]
  323. {
  324. "BUSISEQ",
  325. "BALANCESUBJECT",
  326. "SECONDACCOUNT",
  327. "BUYERCODE",
  328. "INOUTMONEY",
  329. "INOUTTIME",
  330. "FUNDTYPE",
  331. "BILLNO",
  332. "ISVALID",
  333. "MONEY_DELIVER",
  334. "PREBUYERCODE",
  335. "REMARK",
  336. "ORDERNO",
  337. "IMPORTOR",
  338. "IMPORTTIME",
  339. "AFFRIMPER",
  340. "AFFRIMDATE"
  341. };
  342. }
  343. private void button1_Click(object sender, EventArgs e)
  344. {
  345. UIDlgBox.DlgCustChoose custChoose = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgCustChoose(this.ob);
  346. custChoose.CustUse = "100202";
  347. custChoose.SaleOrg = base.GetSaleOrg();
  348. custChoose.ShowDialog();
  349. if (custChoose.DialogResult == DialogResult.OK)
  350. {
  351. this.textBox1.Text = custChoose.customerName;
  352. _buyercode = custChoose.customerNo;
  353. this.Query();
  354. }
  355. }
  356. private string BALANCESUBJECT = "BALANCESUBJECT";
  357. private string BILLNO = "BILLNO";
  358. private string BUSISEQ = "BUSISEQ";
  359. private string BUYERCODE = "BUYERCODE";
  360. private string FUNDTYPE = "FUNDTYPE";
  361. private string IMPORTOR = "IMPORTOR";
  362. private string IMPORTTIME = "IMPORTTIME";
  363. private string INOUTMONEY = "INOUTMONEY";
  364. private string INOUTTIME = "INOUTTIME";
  365. private string ISVALID = "ISVALID";
  366. private string LEAVEMONEY = "LEAVEMONEY";
  367. private string REMARK = "REMARK";
  368. private string TOTALMONEY = "TOTALMONEY";
  369. private string UPDATETIME = "UPDATETIME";
  370. private string MONEY_DELIVER = "MONEY_DELIVER";
  371. private string PREBUYERCODE = "PREBUYERCODE";
  372. private string SECONDACCOUNT = "SECONDACCOUNT";
  373. }
  374. }