You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.Sql; using System.Data.SqlClient; using ManagementSystem.Utility;
namespace ManagementSystem { public partial class PickCustomer : Form { //程式內共用物件
public string strFrmStatus = ""; //表單狀態
public string strPKey = ""; //程式內的Key值
public string strOwnerForm = ""; //設定表單的擁有者
SqlConnection sqlConn = UtilityClass.GetConn(MainForm.strAccountingBookID); SqlCommand sqlCmd = new SqlCommand(); DataSet sdInsurance = new System.Data.DataSet();
public PickCustomer() { InitializeComponent(); }
#region 自定義程式
private void SearchEvent(string strTaxNumber, string strCusName) { try { StringBuilder strSQL = new StringBuilder(""); strSQL.Append("Select CustomerID, CustomerName, TaxNumber "); strSQL.Append("From OTB_CRM_Customers "); strSQL.Append("Where 1 = 1 "); if (strTaxNumber != "") //統一編號
{ strSQL.Append("And TaxNumber like '" + strTaxNumber + "' "); } if (strCusName != "") //客戶名稱
{ strSQL.Append("And CustomerName like '" + strCusName + "' "); }
//進行查詢
dgvDataMaintain.DataSource = UtilityClass.GetSQLResult(strSQL.ToString()).Tables[0];
} catch (Exception ex) { ErrorHandler.WriteErrorLog("PickCustomer.cs", ex); } }
private void CleanForm() { txtTaxNumber.Text = ""; txtCustomerName.Text = ""; }
private void PickItem() { try { //取得資料
string strReturnItem = ""; string strCustomerID = ""; foreach (DataGridViewRow dgvRow in dgvDataMaintain.SelectedRows) { strCustomerID = (string)dgvRow.Cells["cCustomerID"].Value; if (!string.IsNullOrEmpty(strCustomerID)) { strReturnItem = strCustomerID + "|" + dgvRow.Cells["cCustomerName"].Value.ToString(); } }
switch (strOwnerForm) //回傳資料
{ case "PayPlanManagement": PayPlanManagement frmParent = (PayPlanManagement)this.Owner; frmParent.ReturnCustomer(strReturnItem.Split('|')); break;
case "CashFlowForecastEdit": CashFlowForecastEdit frmParent1 = (CashFlowForecastEdit)this.Owner; frmParent1.ReturnCustomer(strReturnItem.Split('|')); break; } this.Close(); } catch (Exception ex) { ErrorHandler.WriteErrorLog("PickCustomer.cs", ex); } } #endregion
#region 事件觸發及問題處理
private void btnClose_Click(object sender, EventArgs e) { this.Close(); }
private void btnClean_Click(object sender, EventArgs e) { CleanForm(); string strTaxNumber = txtTaxNumber.Text.Trim(); string strCusName = txtCustomerName.Text.Trim(); SearchEvent(strTaxNumber, strCusName); }
private void btnSearch_Click(object sender, EventArgs e) { string strTaxNumber = txtTaxNumber.Text.Trim(); string strCusName = txtCustomerName.Text.Trim(); SearchEvent(strTaxNumber, strCusName); }
private void PickCustomer_Load(object sender, EventArgs e) { string strTaxNumber = txtTaxNumber.Text.Trim(); string strCusName = txtCustomerName.Text.Trim(); SearchEvent(strTaxNumber, strCusName); }
private void txtTaxNumber_TextChanged(object sender, EventArgs e) { string strTaxNumber = txtTaxNumber.Text.Trim(); string strCusName = txtCustomerName.Text.Trim();
strTaxNumber = string.IsNullOrEmpty(strTaxNumber) ? "" : strTaxNumber + "%"; strCusName = string.IsNullOrEmpty(strCusName) ? "" : "%" + strCusName + "%"; SearchEvent(strTaxNumber, strCusName); }
private void txtCustomerName_TextChanged(object sender, EventArgs e) { string strTaxNumber = txtTaxNumber.Text.Trim(); string strCusName = txtCustomerName.Text.Trim();
strTaxNumber = string.IsNullOrEmpty(strTaxNumber) ? "" : strTaxNumber + "%"; strCusName = string.IsNullOrEmpty(strCusName) ? "" : "%" + strCusName + "%"; SearchEvent(strTaxNumber, strCusName); }
private void btnPick_Click(object sender, EventArgs e) { PickItem(); }
private void dgvDataMaintain_DoubleClick(object sender, EventArgs e) { PickItem(); } #endregion
} }
|