/// <summary> /// 提交查询条件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSumbitFindCondition_Click(object sender, EventArgs e) { if (panelParameter.Controls.Count == 0) { MessageDialog.ShowPromptMessage("您还没有建立查询条件无法进行此操作!"); return; } m_sentenceSQL = null; try { for (int i = 0; i < panelParameter.Controls.Count; i++) { UserControlFindCondition newControl = panelParameter.Controls[i] as UserControlFindCondition; if (i != panelParameter.Controls.Count - 1) { m_sentenceSQL = m_sentenceSQL + newControl.BuildSQLSentence("", false); } else { m_sentenceSQL = m_sentenceSQL + newControl.BuildSQLSentence("", true); } } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception exce) { Console.WriteLine(exce.Message); return; } }
/// <summary> /// 提交并查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFind_Click(object sender, EventArgs e) { string m_sentenceSQL = null; try { for (int i = 0; i < panelParameter.Controls.Count; i++) { UserControlFindCondition newControl = panelParameter.Controls[i] as UserControlFindCondition; if (i != panelParameter.Controls.Count - 1) { m_sentenceSQL = m_sentenceSQL + newControl.BuildSQLSentence("报表", false); } else { m_sentenceSQL = m_sentenceSQL + newControl.BuildSQLSentence("报表", true); } } } catch (Exception exce) { Console.WriteLine(exce.Message); return; } if (m_sentenceSQL != null) { string error = null; dataGridView1.DataSource = DataSetHelper.SiftDataTable(m_quertResultTable, m_sentenceSQL, out error); } else { dataGridView1.DataSource = m_quertResultTable; } userControlDataLocalizer1.Init(dataGridView1, this.Name, UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID)); dataGridView1.Refresh(); }
/// <summary> /// 提交并查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFind_Click(object sender, EventArgs e) { if (panelParameter.Controls.Count == 0) { MessageDialog.ShowPromptMessage("您还没有建立查询条件无法进行此操作!"); return; } m_sentenceSQL = null; string pareTemp = ""; try { for (int i = 0; i < panelParameter.Controls.Count; i++) { UserControlFindCondition newControl = panelParameter.Controls[i] as UserControlFindCondition; if (i != panelParameter.Controls.Count - 1) { m_sentenceSQL = m_sentenceSQL + newControl.BuildSQLSentence("", false); } else { m_sentenceSQL = m_sentenceSQL + newControl.BuildSQLSentence("", true); if (newControl.FieldName == "单据号") { pareTemp = newControl.DataValue; } } } } catch (Exception exce) { Console.WriteLine(exce.Message); return; } IAuthorization authorization = PlatformFactory.GetObject <IAuthorization>(); string businessID = ""; switch (m_findBusiness) { case "报检入库单": businessID = "报检入库单查询"; break; case "普通入库单": businessID = "普通入库单查询"; break; case "采购退货单": businessID = "采购退货单查询"; break; case "领料单": businessID = "领料单查询"; break; case "领料退库单": businessID = "领料退库单查询"; break; case "销售退库单": businessID = "销售退库单查询"; break; case "销售出库单": businessID = "销售出库单查询"; break; case "产品入库单": businessID = "产品入库单查询"; break; case "报废单": businessID = "报废单查询"; break; case "报废单综合查询": businessID = m_findBusiness; break; case "合同信息管理": businessID = "合同信息综合查询"; break; case "订单信息管理": businessID = "订单信息综合查询"; break; case "自制件入库单": businessID = "自制件入库单查询"; break; case "采购退货单综合查询": businessID = m_findBusiness; break; case "领料单综合查询": businessID = m_findBusiness; break; case "样品确认申请单": businessID = "样品确认申请单综合查询"; break; case "不合格品隔离处置单": businessID = "不合格品隔离处置单查询"; break; case "挑选返工返修单": businessID = "挑选返工返修单查询"; break; case "供应质量信息反馈单": businessID = "供应商质量信息反馈单查询"; break; case "委外报检入库单": businessID = "委外报检入库单查询"; break; case "产品型号变更单": businessID = "产品型号变更单查询"; break; default: businessID = m_findBusiness; break; } string sql = m_sentenceSQL.ToLower(); if (sql.LastIndexOf(" union ") != -1) { MessageDialog.ShowPromptMessage("存在非法字符,无法进行此操作!"); return; } if (businessID == "培训综合统计查询" && (m_sentenceSQL.Contains("培训开始时间") || m_sentenceSQL.Contains("培训终止时间"))) { m_sentenceSQL = m_sentenceSQL + " or 培训开始时间 is null"; } IQueryResult qr = authorization.Query(businessID, null, m_sentenceSQL); if (m_findBusiness == "零星采购申请财务综合查询") { string[] pare = { pareTemp }; qr = authorization.QueryMultParam(businessID, m_sentenceSQL, pare); } if (m_findBusiness == "出差综合查询") { string[] pare = { BasicInfo.DeptCode }; qr = authorization.QueryMultParam(businessID, m_sentenceSQL, pare); } if (m_findBusiness == "出差人员查看") { string[] pare = { BasicInfo.LoginID }; qr = authorization.QueryMultParam(businessID, m_sentenceSQL, pare); } if (m_findBusiness == "订单入库单综合查询") { qr = authorization.QueryMultParam(businessID, m_sentenceSQL, m_proParameter); } if (!qr.Succeeded) { m_quertResultTable = null; MessageDialog.ShowErrorMessage(qr.Error); } else { m_quertResultTable = qr.DataCollection.Tables[0]; lblAmount.Text = m_quertResultTable.Rows.Count.ToString(); } dataGridView1.DataSource = m_quertResultTable; for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (dataGridView1.Columns[i].Name.Contains("标志") || dataGridView1.Columns[i].Name.Contains("领料类型") || dataGridView1.Columns[i].Name.Contains("人编码") || //dataGridView1.Columns[i].Name.Contains("签名") || dataGridView1.Columns[i].Name.Contains("权限控制") || dataGridView1.Columns[i].Name.Contains("序号")) { dataGridView1.Columns[i].Visible = false; } } #region 隐藏不允许查看的列 if (qr.HideFields != null && qr.HideFields.Length > 0) { for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (qr.HideFields.Contains(dataGridView1.Columns[i].Name)) { dataGridView1.Columns[i].Visible = false; } } } #endregion if (!BasicInfo.ListRoles.Contains(CE_RoleEnum.采购账务管理员.ToString()) && !BasicInfo.ListRoles.Contains(CE_RoleEnum.会计.ToString())) { for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (dataGridView1.Columns[i].Name.Contains("单价") || dataGridView1.Columns[i].Name.Contains("金额")) { dataGridView1.Columns[i].Visible = false; } } } dataGridView1.Refresh(); }
/// <summary> /// 测试过滤条件 /// </summary> /// <returns>成功返回true</returns> private bool TestFilterCondition() { int leftParentheses = 0; int rightParentheses = 0; m_sentenceSQL = ""; try { for (int i = 0; i < panelParameter.Controls.Count; i++) { UserControlFindCondition control = panelParameter.Controls[i] as UserControlFindCondition; leftParentheses += control.LeftParentheses.Length == 0 ? 0 : 1; rightParentheses += control.RightParentheses.Length == 0 ? 0 : 1; if (i != panelParameter.Controls.Count - 1) { m_sentenceSQL = m_sentenceSQL + control.BuildSQLSentence("", false); } else { m_sentenceSQL = m_sentenceSQL + control.BuildSQLSentence("", true); } } if (leftParentheses != rightParentheses) { MessageDialog.ShowPromptMessage("左右括号数量不匹配"); return(false); } } catch (Exception exce) { Console.WriteLine(exce.Message); return(false); } IAuthorization authorization = PlatformFactory.GetObject <IAuthorization>(); string businessID = ""; switch (m_findBusiness) { case "报检入库单": businessID = "报检入库单查询"; break; case "普通入库单": businessID = "普通入库单查询"; break; case "采购退货单": businessID = "采购退货单查询"; break; case "领料单": businessID = "领料单查询"; break; case "领料退库单": businessID = "领料退库单查询"; break; case "销售退库单": businessID = "销售退库单查询"; break; case "销售出库单": businessID = "销售出库单查询"; break; case "产品入库单": businessID = "产品入库单查询"; break; case "还货单": businessID = "还货单查询"; break; case "借货单": businessID = "借货单查询"; break; case "报废单": businessID = "报废单查询"; break; case "合同信息管理": businessID = "合同信息综合查询"; break; case "订单信息管理": businessID = "订单信息综合查询"; break; case "自制件入库单": businessID = "自制件入库单查询"; break; case "产品型号变更单": businessID = "产品型号变更单查询"; break; } m_queryResult = authorization.Query(businessID, null, m_sentenceSQL); if (!m_queryResult.Succeeded) { MessageDialog.ShowErrorMessage(m_queryResult.Error); return(false); } else { return(true); } }