public DataSet GetDataFromSelectedTable(string strSQL, string tableName, DataAccess_Net.clsDataAccess oDataAccess) { DataSet dsData = new DataSet(); try { strSQL = strSQL + tableName; dsData = oDataAccess.GetDataSet(strSQL, null, 20); dsData.Tables[0].TableName = "FormInfo"; } catch (Exception ex) { // throw ex; errorhandle(ex.Message); } finally { //objParam = null; //colParams = null; //oDataAccess = null; } return(dsData); }
public void ControlBind(string tableName) { this.errorProvider1.Clear(); DataSet dsData = new DataSet(); string strSQL; int i = this.BindingContext[dsMain.Tables[0]].Position; this.txtCatName.DataBindings.Clear(); this.txtDesc.DataBindings.Clear(); this.ChkActivat.DataBindings.Clear(); //Birendra : Bug-7896 on 24/12/2012 :Start: if (dsMain.Tables[0].Rows.Count > 1 && i == 0) { HandleNavigationButtons(false, false, true, true); } else if (dsMain.Tables[0].Rows.Count > 1) { HandleNavigationButtons(true, true, true, true); } else { HandleNavigationButtons(false, false, false, false); } //Birendra : Bug-7896 on 24/12/2012 :end: this.txtCatName.DataBindings.Add("Text", dsMain.Tables[0], "cost_cat_name"); this.txtDesc.DataBindings.Add("Text", dsMain.Tables[0], "descript"); this.ChkActivat.DataBindings.Add("checked", dsMain.Tables[0], "activat", true, DataSourceUpdateMode.OnPropertyChanged); strSQL = this._strSQL + tableName; dsData = oDataAccess.GetDataSet(strSQL, null, 20); dsData.Tables[0].TableName = "TempData"; //this.cmbGroup.DataSource = dsData.Tables[0] ; //this.cmbGroup.DisplayMember = "cost_cat_name"; //this.cmbGroup.ValueMember = "cost_cat_name"; //this.cmbGroup.DataBindings.Add("SelectedValue",dsMain.Tables[0],"group_cost"); }
public int SaveFormData(string tableName, DataAccess_Net.clsDataAccess oDataAccess) { int id = 0; DataSet dsData = new DataSet(); StringBuilder strFieldNames = new StringBuilder(); StringBuilder strFieldValues = new StringBuilder(); string strSQL = ""; try { //strSQL = "SELECT * FROM " + tableName +" Where cost_cat_name = "+"'"+this.cmbGroup.Text +"'"; //dsData = oDataAccess.GetDataSet(strSQL, null, 20); //dsData.Tables[0].TableName = "TmpData"; // int j = this.BindingContext[dsMain.Tables[0]].Position; CurrencyManager cm = (CurrencyManager)this.BindingContext[dsMain.Tables[0]]; DataRow findRow = ((DataRowView)cm.Current).Row; int j = dsMain.Tables[0].Rows.IndexOf(findRow); //if (dsData.Tables[0].Rows.Count == 0) //{ // dsMain.Tables[0].Rows[0]["gr_cost_id"] = 9999; //} //else //{ // dsMain.Tables[0].Rows[j]["gr_cost_id"] = dsData.Tables[0].Rows[0]["cost_cat_id"]; //} //dsMain.Tables[0].AcceptChanges(); if (this.pAddMode) { oDataAccess.BeginTransaction(); strSQL = InsertStatment(tableName, null); oDataAccess.ExecuteSQLStatement(strSQL, null, 20, true); // Added By Pankaj B. on 16-02-2015 for Bug-25197 Start strSQL = "select cmastcode,dbexport from Tbl_DataExport_Mast where ctype='M' and cmastcode='cost_Cat_mast'"; dsExport = oDataAccess.GetDataSet(strSQL, null, 25); if (dsExport.Tables[0].Rows.Count != 0) { ExportTbl = dsExport.Tables[0].Rows[0]["dbexport"].ToString().Trim() + ".dbo." + tableName; strSQL = InsertStatment(ExportTbl, null); oDataAccess.ExecuteSQLStatement(strSQL, null, 20, true); } // Added By Pankaj B. on 16-02-2015 for Bug-25197 End oDataAccess.CommitTransaction(); } if (this.pEditMode) { oDataAccess.BeginTransaction(); strSQL = UpdateStatment(tableName, "cost_cat_id") + " where cost_cat_id=" + dsMain.Tables[0].Rows[j]["cost_cat_id"].ToString(); oDataAccess.ExecuteSQLStatement(strSQL, null, 20, true); // Added By Pankaj B. on 16-02-2015 for Bug-25197 Start strSQL = "select cmastcode,dbexport from Tbl_DataExport_Mast where ctype='M' and cmastcode='cost_Cat_mast'"; dsExport = oDataAccess.GetDataSet(strSQL, null, 25); if (dsExport.Tables[0].Rows.Count != 0) { ExportTbl = dsExport.Tables[0].Rows[0]["dbexport"].ToString().Trim() + ".dbo." + tableName; strSQL = UpdateStatment(ExportTbl, "cost_cat_id") + " where cost_cat_id=(select cost_cat_id from " + ExportTbl + " where cost_cat_name= '" + dsMain.Tables[0].Rows[j]["cost_cat_name"].ToString() + "')"; oDataAccess.ExecuteSQLStatement(strSQL, null, 20, true); } // Added By Pankaj B. on 16-02-2015 for Bug-25197 End oDataAccess.CommitTransaction(); } } catch (Exception ex) { // throw ex; errorhandle(ex.Message); } finally { //objParam = null; //colParams = null; //oDataAccess = null; } return(id); }