private void Cost_Cat_Mast_Load(object sender, EventArgs e)
        {
            DataAccess_Net.clsDataAccess._databaseName = this.pComDbnm;
            DataAccess_Net.clsDataAccess._serverName   = this.pServerName;
            DataAccess_Net.clsDataAccess._userID       = this.pUserId;
            DataAccess_Net.clsDataAccess._password     = this.pPassword;
            oDataAccess = new DataAccess_Net.clsDataAccess();

            CultureInfo ci = new CultureInfo("en-US");

            ci.DateTimeFormat.ShortDatePattern  = "dd/MM/yyyy";
            Thread.CurrentThread.CurrentCulture = ci;
            validations                = new Dictionary <string, string>();
            this.pAppPath              = Application.StartupPath;
            this.btnCancel.Enabled     = false;
            this.btnLocate.Enabled     = true;
            this.btnPreview.Enabled    = false;
            this.btnPrint.Enabled      = false;
            this.btnHelp.Enabled       = false;
            this.btnCalculator.Enabled = false;
            this.btnExit.Visible       = false;
            this.btnEmail.Enabled      = false;
            this.panel1.Enabled        = false;
            this.panel2.Visible        = false;
            this.Height                = 188;


            this._strSQL = "SELECT cost_cat_id,cost_cat_name,descript,activat FROM ";
            dsMain       = GetDataFromSelectedTable(this._strSQL, this._TableName, oDataAccess);
            ControlBind(this._TableName);
            this.mInsertProcessIdRecord();
        }
        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 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);
        }