private void gvOvertimeLimits_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column == colol_code) { if (e.Value != null && e.Value != DBNull.Value) { string sCode = ""; try { sCode = e.Value.ToString(); } catch { } DataTable dt = hmConn.SQLExecutor.ExecuteDataAdapter("Select ol_desc, ol_ot, ol_dt, ol_week_ot, ol_week_dt From ot_limit Where pri_id = 0 and ol_code = '" + sCode + "'", hmConn.TRConnection); if (hmConn.SQLExecutor.Exception != null) { Popups.ShowPopup("Unable to retrive description for Over Time Code: " + hmConn.SQLExecutor.Exception.Message); } if (dt.Rows.Count > 0) { gvOvertimeLimits.SetFocusedRowCellValue(colol_desc, dt.Rows[0]["ol_desc"]); gvOvertimeLimits.SetFocusedRowCellValue(colol_ot, dt.Rows[0]["ol_ot"]); gvOvertimeLimits.SetFocusedRowCellValue(colol_dt, dt.Rows[0]["ol_dt"]); gvOvertimeLimits.SetFocusedRowCellValue(colol_week_ot, dt.Rows[0]["ol_week_ot"]); gvOvertimeLimits.SetFocusedRowCellValue(colol_week_dt, dt.Rows[0]["ol_week_dt"]); } } } }
private void bntOK_Click(object sender, EventArgs e) { string sqlstr = "select count(id) from working_burden_type where selected = 'T' and username = '******'"; int count = Convert.ToInt32(ReflexCon.SQLExecutor.ExecuteScalar(sqlstr, ReflexCon.TRConnection)); if (count == 0) { if (Popups.ShowPopup("Are you sure you wish to select no burdens?", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { DialogResult = DialogResult.OK; Close(); return; } else { return; } } else { sqlstr = " insert costing_burdens ( pri_id, burden_type_id, calc_type, reg_rate, ot_rate, dt_rate, gl_account, IsCeiling) " + " select " + iPri_ID.ToString() + ", burden_type_id ,calc_type, reg_rate, ot_rate, dt_rate, gl_account, IsCeiling from working_burden_type where selected ='T' and username = '******'";; ReflexCon.SQLExecutor.ExecuteNonQuery(sqlstr, ReflexCon.TRConnection); if (ReflexCon.SQLExecutor.Exception != null) { Popups.ShowPopup("Unable to add burdens: " + ReflexCon.SQLExecutor.Exception.Message); } DialogResult = DialogResult.OK; Close(); } }
private void riLink_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph) { int ComplianceID = ucSV.GetFocusedCompliance(); if (ComplianceID == -1) { Popup.ShowPopup("Please select a subcontractor compliance record to link the document to."); } else { if (Popup.ShowPopup("Are you sure you want to link the selected attachment with the selected subcontractor compliance?", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { DataRow dr = gvAttachments.GetDataRow(gvAttachments.FocusedRowHandle); object oRep_ID = dr["FileRepository_ID"]; object oRel_ID = dr["Rel_ID"]; string sSQL = @"declare @FileRepository_ID int insert into CFS_FileRepository ([FileName], FileData, AddedBy, DateAdded, FileType, Mime_type, InternalOnly, FileStatus, FileOrigin, OriginLink, OriginLink2, permanent_tf, CurrentTCSE_ID) select [FileName], FileData, AddedBy, DateAdded, FileType, Mime_type, InternalOnly, FileStatus, FileOrigin, OriginLink, OriginLink2, permanent_tf, CurrentTCSE_ID from CFS_FileRepository where ID = " + oRep_ID + @" select @FileRepository_ID=SCOPE_IDENTITY() insert into CFS_FileReleations (FileRepository_ID, RelType, RelType_ID, ContextItemID, FileOrigin, TargetPrint, Comment, LinkOrigin, Supplier_ID, pri_id, AP_INV_HEADER_ID, PO_ID) select @FileRepository_ID, 'SUPPSUBCON', " + ComplianceID + @", ContextItemID, FileOrigin, TargetPrint, Comment, LinkOrigin, Supplier_ID, pri_id, AP_INV_HEADER_ID, PO_ID from CFS_FileReleations where ID = " + oRel_ID; Connection.SQLExecutor.ExecuteNonQuery(sSQL, Connection.TRConnection); object oEX = Connection.SQLExecutor.Exception; if (oEX == null) { Popup.ShowPopup("Attachment has been linked."); } else { Popup.ShowPopup("Error linking attachment."); } } } } }
private void bntOK_Click(object sender, EventArgs e) { gvSelectableEquiClasses.UpdateCurrentRow(); if (dsEquipClassSelection1.fa_class.Select("Selected = 0").Count() == dsEquipClassSelection1.fa_class.Rows.Count) { if (frmMessageBox.ShowPopup("Are you sure you wish to select no equipment classes?", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { DialogResult = DialogResult.OK; Close(); return; } else { return; } } DataRow[] drSelectedItem = dsEquipClassSelection1.fa_class.Select("Selected = 1"); System.Text.StringBuilder sbInsert = new StringBuilder(); string preSql = "declare @id int "; string execSql = " select @id = SCOPE_IDENTITY() exec FA_EqiClassPayRate @id "; foreach (DataRow Row in drSelectedItem) { if (Row["facl_code"] != DBNull.Value && Row["facl_code"] != null) { sbInsert.Append(" Insert Into costing_equipment_class (pri_id, eqi_Class, rate_desc, rate, CostRate, UseEquipOverride) "); sbInsert.Append("Select " + iPri_ID.ToString() + ", facl_code, facl_desc, IsNull(fac_bill_out,0.00), IsNull(fac_cost_rate,0.00), 'F' From fa_class where facl_code = '" + Row["facl_code"].ToString() + "' "); sbInsert.Append(execSql); sbInsert.Append("\r\n"); } } ReflexCon.SQLExecutor.ExecuteNonQuery(preSql + sbInsert.ToString(), ReflexCon.TRConnection); if (ReflexCon.SQLExecutor.Exception != null) { frmMessageBox.ShowPopup("Unable to add equipment classes: " + ReflexCon.SQLExecutor.Exception.Message); } DialogResult = DialogResult.OK; Close(); }
private bool AllowDelete() { bool doDeleting = false; try { if (this.Popup.ShowPopup(this, "Are you sure you want to delete?", "Confirmation", WS_Popups.frmPopup.PopupType.Yes_No) == WS_Popups.frmPopup.PopupResult.Yes) { doDeleting = true; } } catch (Exception ex) { doDeleting = false; Popup.ShowPopup("Error found in deleting process: " + ex.Message.ToString()); } return(doDeleting); }
private void bntOK_Click(object sender, EventArgs e) { gvSelectableWorkClasses.UpdateCurrentRow(); if (dsWorkClassSelection1.work_class.Select("Selected = 0").Count() == dsWorkClassSelection1.work_class.Rows.Count) { if (frmMessageBox.ShowPopup("Are you sure you wish to select no work classes?", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { DialogResult = DialogResult.OK; Close(); return; } else { return; } } DataRow[] drSelectedItem = dsWorkClassSelection1.work_class.Select("Selected = 1"); System.Text.StringBuilder sbInsert = new StringBuilder(); foreach (DataRow Row in drSelectedItem) { if (Row["wc_code"] != DBNull.Value && Row["wc_code"] != null) { sbInsert.Append("Insert Into costing_work_class (WC_Code, pri_id, Standard, OverTime, DoubleTime, TravelTime, CeilingCost) "); sbInsert.Append("Select WC_Code, " + iPri_ID.ToString() + ", IsNull(Regular,0.00), IsNull(OverTime,0.00), IsNull(DoubleTime,0.00), IsNull(Travel,0.00), isnull(ceilingcost,0) From work_class where wc_code = '" + Row["wc_code"].ToString() + "' "); sbInsert.Append("\r\n"); } } ReflexCon.SQLExecutor.ExecuteNonQuery(sbInsert.ToString(), ReflexCon.TRConnection); if (ReflexCon.SQLExecutor.Exception != null) { frmMessageBox.ShowPopup("Unable to add work classes: " + ReflexCon.SQLExecutor.Exception.Message); } DialogResult = DialogResult.OK; Close(); }
private void ucStakeholderType_Load(object sender, EventArgs e) { Popup = new WS_Popups.frmPopup(DevXMgr); try { dsPC_StakeholderType_Lookup1.Clear(); daPC_StakeholderType_Lookup.Fill(dsPC_StakeholderType_Lookup1); dsAlert_PC_Stakeholder1.Clear(); daAlert_PC_Stakeholder.Fill(dsAlert_PC_Stakeholder1); } catch (Exception ex) { Popup.ShowPopup("Error loading lookup's : " + ex.Message); } gGrid = new TUC_GridG.GridG(Connection.CompanyServer, Connection.TRDB, gvStakeholderType, daAlert_PC_Stakeholder, dsAlert_PC_Stakeholder1); gGrid.AskBeforeDelete = false; gGrid.AllowTabCreateNewRecord = true; gGrid.AllowDelete += new TUC_GridG.GridG.AllowDeleteDelegate(gGrid_AllowDelete); DevXMgr.FormInit(this); }
private void gvWorkClasses_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { //Standard if (gvWorkClasses.GetDataRow(e.RowHandle) != null) { if (gvWorkClasses.GetDataRow(e.RowHandle)["WC_Code"] == DBNull.Value || gvWorkClasses.GetDataRow(e.RowHandle)["WC_Code"] == null) { e.ErrorText = "Work Code cannot be blank."; e.Valid = false; } double dRate = 0; if (e.Valid) { if (gvWorkClasses.GetDataRow(e.RowHandle)["Standard"] == DBNull.Value || gvWorkClasses.GetDataRow(e.RowHandle)["Standard"] == null) { e.ErrorText = "Regular rate cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvWorkClasses.GetDataRow(e.RowHandle)["Standard"]); } catch { } if (dRate < 0) { e.ErrorText = "Regular rate cannot be negative."; e.Valid = false; } } } if (e.Valid) { dRate = 0; if (gvWorkClasses.GetDataRow(e.RowHandle)["OverTime"] == DBNull.Value || gvWorkClasses.GetDataRow(e.RowHandle)["OverTime"] == null) { e.ErrorText = "Overtime rate cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvWorkClasses.GetDataRow(e.RowHandle)["OverTime"]); } catch { } if (dRate < 0) { e.ErrorText = "Overtime rate cannot be negative."; e.Valid = false; } } } if (e.Valid) { dRate = 0; if (gvWorkClasses.GetDataRow(e.RowHandle)["DoubleTime"] == DBNull.Value || gvWorkClasses.GetDataRow(e.RowHandle)["DoubleTime"] == null) { e.ErrorText = "Double time rate cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvWorkClasses.GetDataRow(e.RowHandle)["DoubleTime"]); } catch { } if (dRate < 0) { e.ErrorText = "Double time rate cannot be negative."; e.Valid = false; } } } if (e.Valid) { dRate = 0; if (gvWorkClasses.GetDataRow(e.RowHandle)["TravelTime"] == DBNull.Value || gvWorkClasses.GetDataRow(e.RowHandle)["TravelTime"] == null) { e.ErrorText = "Travel time rate cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvWorkClasses.GetDataRow(e.RowHandle)["TravelTime"]); } catch { } if (dRate < 0) { e.ErrorText = "Travel time rate cannot be negative."; e.Valid = false; } } } if (e.Valid) { dRate = 0; if (gvWorkClasses.GetDataRow(e.RowHandle)["CeilingCost"] == DBNull.Value || gvWorkClasses.GetDataRow(e.RowHandle)["CeilingCost"] == null) { e.ErrorText = "Ceiling Cost amount cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvWorkClasses.GetDataRow(e.RowHandle)["CeilingCost"]); } catch { } if (dRate < 0) { e.ErrorText = "Ceiling Cost amount cannot be negative."; e.Valid = false; } } } // validate the row when 'scheduling' is being disabled if (e.Valid) { object oSchedulingProposed = false; object oScheduling = false; try { oSchedulingProposed = gvWorkClasses.GetDataRow(e.RowHandle)[colsch_enabled.FieldName, DataRowVersion.Proposed]; } catch { } try { oScheduling = gvWorkClasses.GetDataRow(e.RowHandle)[colsch_enabled.FieldName, DataRowVersion.Current]; } catch { } object cwc_id = -1; if (oSchedulingProposed == null || oSchedulingProposed == DBNull.Value) { oSchedulingProposed = false; } if (oScheduling == null || oScheduling == DBNull.Value) { oScheduling = false; } if (gvWorkClasses.GetDataRow(e.RowHandle)[colcwc_id.FieldName] != null) { cwc_id = gvWorkClasses.GetDataRow(e.RowHandle)[colcwc_id.FieldName]; } if (Convert.ToBoolean(oSchedulingProposed) == false) { if (IsWorkClassScheduledWithEmployees(Convert.ToInt32(cwc_id))) { string msg = "Employees have been scheduled against the selected work class. By disabling scheduling, note that the existing scheduled employees will be removed. " + Environment.NewLine + "Are you sure you want to continue ?"; if (Popups.ShowPopup(msg, "Warning", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { // delete all records from the tr.costing_working_class_emp hmConn.SQLExecutor.ExecuteNonQuery("DELETE FROM costing_work_class_emp WHERE cwc_id = " + cwc_id, hmConn.TRConnection); } else { gvWorkClasses.SetFocusedRowCellValue(colsch_enabled, oScheduling); } } } } } if (!e.Valid) { bCustomErrorMsg = true; } //DataRow dr = gvWorkClasses.GetDataRow(e.RowHandle); //if (dr != null) //{ // double dRate = 0; // object objResult = dr["Standard"]; // if (objResult != null && objResult != DBNull.Value) // { // dRate = Convert.ToDouble(objResult); // } // if (dRate < 0) // { // Popups.ShowPopup("Regular rate cannot be negative."); // e.Valid = false; // return; // } // objResult = dr["OverTime"]; // if (objResult != null && objResult != DBNull.Value) // { // dRate = Convert.ToDouble(objResult); // } // if (dRate < 0) // { // Popups.ShowPopup("Overtime rate cannot be negative."); // e.Valid = false; // return; // } // objResult = dr["DoubleTime"]; // if (objResult != null && objResult != DBNull.Value) // { // dRate = Convert.ToDouble(objResult); // } // if (dRate < 0) // { // Popups.ShowPopup("Double time rate cannot be negative."); // e.Valid = false; // return; // } // objResult = dr["TravelTime"]; // if (objResult != null && objResult != DBNull.Value) // { // dRate = Convert.ToDouble(objResult); // } // if (dRate < 0) // { // Popups.ShowPopup("Travel time rate cannot be negative."); // e.Valid = false; // return; // } //} }
private void gvEqiClass_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { if (gvEqiClass.GetDataRow(e.RowHandle) != null) { if (gvEqiClass.GetDataRow(e.RowHandle)["eqi_Class"] == DBNull.Value || gvEqiClass.GetDataRow(e.RowHandle)["eqi_Class"] == null) { e.Valid = false; e.ErrorText = "Code cannot be blank."; } double dRate = 0; if (e.Valid) { if (gvEqiClass.GetDataRow(e.RowHandle)["rate"] == DBNull.Value || gvEqiClass.GetDataRow(e.RowHandle)["rate"] == null) { e.ErrorText = "Billing rate cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvEqiClass.GetDataRow(e.RowHandle)["rate"]); } catch { } if (dRate < 0) { e.ErrorText = "Billing rate cannot be negative."; e.Valid = false; } } } if (e.Valid) { if (gvEqiClass.GetDataRow(e.RowHandle)["CostRate"] == DBNull.Value || gvEqiClass.GetDataRow(e.RowHandle)["CostRate"] == null) { e.ErrorText = "Cost rate cannot be blank."; e.Valid = false; } else { try { dRate = Convert.ToDouble(gvEqiClass.GetDataRow(e.RowHandle)["CostRate"]); } catch { } if (dRate < 0) { e.ErrorText = "Cost rate cannot be negative."; e.Valid = false; } } } // validation on 'Scheduled' column value if (e.Valid) { object oSchedulingProposed = false; object oScheduling = false; try { oSchedulingProposed = gvEqiClass.GetDataRow(e.RowHandle)[colsch_enabled.FieldName, DataRowVersion.Proposed]; } catch { } try { oScheduling = gvEqiClass.GetDataRow(e.RowHandle)[colsch_enabled.FieldName, DataRowVersion.Current]; } catch { } object cer_id = -1; if (oSchedulingProposed == null || oSchedulingProposed == DBNull.Value) { oSchedulingProposed = false; } if (oScheduling == null || oScheduling == DBNull.Value) { oScheduling = false; } if (gvEqiClass.GetDataRow(e.RowHandle)[colcer_id.FieldName] != null) { cer_id = gvEqiClass.GetDataRow(e.RowHandle)[colcer_id.FieldName]; } if (Convert.ToBoolean(oSchedulingProposed) == false) { if (IsCostingClassScheduledWithEquipment(Convert.ToInt32(cer_id))) { string msg = "Equipment have been scheduled against the selected equipment class. By disabling scheduling, note that the existing scheduled equipment will be removed. " + Environment.NewLine + "Are you sure you want to continue ?"; if (Popups.ShowPopup(msg, "Warning", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { // delete all records from the tr.costing_equipment_class_equip hmConn.SQLExecutor.ExecuteNonQuery("DELETE FROM costing_equipment_class_equip WHERE cer_id = " + cer_id, hmConn.TRConnection); } else { gvEqiClass.SetFocusedRowCellValue(colsch_enabled, oScheduling); } } } } } if (!e.Valid) { bCustomErrorMsg = true; } //DataRow dr = gvEqiClass.GetDataRow(e.RowHandle); //if (dr != null) //{ // double dRate = 0; // object objResult = dr["rate"]; // if (objResult != null && objResult != DBNull.Value) // { // dRate = Convert.ToDouble(objResult); // } // if (dRate < 0) // { // Popups.ShowPopup("Billing Rate cannot be negative."); // e.Valid = false; // return; // } // objResult = dr["costrate"]; // if (objResult != null && objResult != DBNull.Value) // { // dRate = Convert.ToDouble(objResult); // } // if (dRate < 0) // { // Popups.ShowPopup("Cost Rate cannot be negative."); // e.Valid = false; // return; // } //} }
private void gvBurden_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { int burdenID = 0; int typeID = 0; double dRate = 0; double regHR, OTHR, DTHR; // regualr hours, over-time hours and double time hours DataRow dr = gvBurden.GetDataRow(e.RowHandle); if (dr != null) { object objResult = dr["burden_type_id"]; if (objResult == null || objResult == DBNull.Value) { Popups.ShowPopup("A burden type is required."); e.Valid = false; return; } typeID = Convert.ToInt32(objResult); objResult = dr["cb_id"]; if (objResult != null && objResult != DBNull.Value) { burdenID = Convert.ToInt32(objResult); } string sqlStr = "select count(*) from costing_burdens where pri_id = " + _pri_id.ToString() + " and cb_id <> " + burdenID.ToString() + " and burden_type_id = " + typeID.ToString(); int count = Convert.ToInt32(hmConn.SQLExecutor.ExecuteScalar(sqlStr, hmConn.TRConnection)); if (count > 0) { Popups.ShowPopup("This burden type already setup."); e.Valid = false; return; } // objResult = dr["reg_rate"]; if (objResult != null && objResult != DBNull.Value) { dRate = Convert.ToDouble(objResult); } if (dRate < 0) { Popups.ShowPopup("Regular Hours cannot be negative."); e.Valid = false; return; } else { regHR = dRate; } objResult = dr["ot_rate"]; if (objResult != null && objResult != DBNull.Value) { dRate = Convert.ToDouble(objResult); } if (dRate < 0) { Popups.ShowPopup("Overtime Hours cannot be negative."); e.Valid = false; return; } else { OTHR = dRate; } objResult = dr["dt_rate"]; if (objResult != null && objResult != DBNull.Value) { dRate = Convert.ToDouble(objResult); } if (dRate < 0) { Popups.ShowPopup("Double Hours cannot be negative."); e.Valid = false; return; } else { DTHR = dRate; } objResult = dr["gl_account"]; if (objResult.ToString() == "") { Popups.ShowPopup("GL Account is required."); e.Valid = false; return; } // if it is Ceiling Burden, do not allow the line to save with Regular, OT, DT hours other than 0 if (IsCeilingBurden(gvBurden.FocusedRowHandle)) { if (regHR != 0 || OTHR != 0 || DTHR != 0) { if (Popups.ShowPopup("Regular Hours, Overtime Hours and Double Hours must each equal to 0. Do you want to set it to zero ?", WS_Popups.frmPopup.PopupType.OK_Cancel) == WS_Popups.frmPopup.PopupResult.OK) { dr["reg_rate"] = dr["ot_rate"] = dr["dt_rate"] = 0; gvBurden.SetFocusedRowCellValue("reg_rate", 0); gvBurden.SetFocusedRowCellValue("ot_rate", 0); gvBurden.SetFocusedRowCellValue("dt_rate", 0); } else { e.Valid = false; return; } } } } }
private void btnSearch_Click(object sender, EventArgs e) { object oActiveOnly = (chkActive.EditValue == null || chkActive.EditValue == DBNull.Value) ? DBNull.Value : chkActive.EditValue; object oPri_id = (lueProjNo.EditValue == null || lueProjNo.EditValue == DBNull.Value) ? DBNull.Value : lueProjNo.EditValue; object oPri_id2 = (lueProject.EditValue == null || lueProject.EditValue == DBNull.Value) ? DBNull.Value : lueProject.EditValue; object oPurchaser_ID = (luePurchaser.EditValue == null || luePurchaser.EditValue == DBNull.Value) ? DBNull.Value : luePurchaser.EditValue; object oMasterAgreeNo = (cboMasterAgreement.EditValue == null || cboMasterAgreement.EditValue == DBNull.Value || cboMasterAgreement.EditValue.ToString().Trim().Equals("")) ? DBNull.Value : cboMasterAgreement.EditValue; object oAgreeNo = (cboAgreement.EditValue == null || cboAgreement.EditValue == DBNull.Value || cboAgreement.EditValue.ToString().Trim().Equals("")) ? DBNull.Value : cboAgreement.EditValue; object oLot_num = (cboLot.EditValue == null || cboLot.EditValue == DBNull.Value || cboLot.EditValue.ToString().Trim().Equals("")) ? DBNull.Value : cboLot.EditValue; object oBlock_num = (cboBlock.EditValue == null || cboBlock.EditValue == DBNull.Value || cboBlock.EditValue.ToString().Trim().Equals("")) ? DBNull.Value : cboBlock.EditValue; object oPlan_num = (cboPlan.EditValue == null || cboPlan.EditValue == DBNull.Value || cboPlan.EditValue.ToString().Trim().Equals("")) ? DBNull.Value : cboPlan.EditValue; object oLevy_ID = (lueLevy.EditValue == null || lueLevy.EditValue == DBNull.Value) ? DBNull.Value : lueLevy.EditValue; object oLevyType_ID = (lueLevyType.EditValue == null || lueLevyType.EditValue == DBNull.Value) ? DBNull.Value : lueLevyType.EditValue; using (SqlConnection sqlcon = new SqlConnection(Connection.TRConnection)) { string sSQL = @"AP_LevySelect"; SqlCommand cmd = new SqlCommand(sSQL, sqlcon); cmd.CommandType = CommandType.StoredProcedure; SqlParameter pUsername = new SqlParameter("@username", Connection.MLUser); SqlParameter pActiveOnly = new SqlParameter("@activeOnly", oActiveOnly); SqlParameter pPri_id = new SqlParameter("@pri_id", oPri_id); SqlParameter pPri_id2 = new SqlParameter("@pri_id2", oPri_id2); SqlParameter pPurchaser_ID = new SqlParameter("@purchaser_id", oPurchaser_ID); SqlParameter pMasterAgreeNo = new SqlParameter("@masterAgreeNo", oMasterAgreeNo); SqlParameter pAgreeNo = new SqlParameter("@agreeNo", oAgreeNo); SqlParameter pLot_num = new SqlParameter("@lot_num", oLot_num); SqlParameter pBlock_num = new SqlParameter("@block_num", oBlock_num); SqlParameter pPlan_num = new SqlParameter("@plan_num", oPlan_num); SqlParameter pLevy_ID = new SqlParameter("@Levy_ID", oLevy_ID); SqlParameter pLevyType_ID = new SqlParameter("@LevyType_ID", oLevyType_ID); SqlParameter pSupplier_id = new SqlParameter("@supplier_id", Supplier_ID); SqlParameter pAP_INV_HEADER_ID = new SqlParameter("@ap_inv_header_id", AP_INV_HEADER_ID); cmd.Parameters.Add(pUsername); cmd.Parameters.Add(pActiveOnly); cmd.Parameters.Add(pPri_id); cmd.Parameters.Add(pPri_id2); cmd.Parameters.Add(pPurchaser_ID); cmd.Parameters.Add(pMasterAgreeNo); cmd.Parameters.Add(pAgreeNo); cmd.Parameters.Add(pLot_num); cmd.Parameters.Add(pBlock_num); cmd.Parameters.Add(pPlan_num); cmd.Parameters.Add(pLevy_ID); cmd.Parameters.Add(pLevyType_ID); cmd.Parameters.Add(pSupplier_id); cmd.Parameters.Add(pAP_INV_HEADER_ID); try { cmd.Connection.Open(); cmd.ExecuteNonQuery(); dsLevySearch1.Clear(); daLevySearch.Fill(dsLevySearch1); gvLevy.BestFitColumns(); } catch (Exception) { Popup.ShowPopup("Error running search."); } finally { cmd.Connection.Close(); } } }