public ICollection <ErrorHandler> BulkInsert(string argExcelPath, string argQuery, string strTableName, string argFileExt, string argUserName, string argClientCode)
        {
            DataTable           dtExcel         = null;
            MaterialType        ObjMaterialType = null;
            string              xConnStr        = "";
            string              strSheetName    = "";
            DataSet             dsExcel         = new DataSet();
            DataTable           dtTableSchema   = new DataTable();
            OleDbConnection     objXConn        = null;
            OleDbDataAdapter    objDataAdapter  = new OleDbDataAdapter();
            List <ErrorHandler> lstErr          = new List <ErrorHandler>();

            if (argFileExt.ToString() == ".xls")
            {
                xConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                           "Data Source=" + argExcelPath.Trim() + ";" +
                           "Extended Properties=Excel 8.0";
            }
            else
            {
                xConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                           "Data Source=" + argExcelPath.Trim() + ";" +
                           "Extended Properties=Excel 12.0";
            }

            try
            {
                objXConn = new OleDbConnection(xConnStr);
                objXConn.Open();

                dtTableSchema = objXConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                if (argFileExt.ToString() == ".xls")
                {
                    strSheetName = Convert.ToString(dtTableSchema.Rows[0]["TABLE_NAME"]);
                }
                else
                {
                    strSheetName = Convert.ToString(dtTableSchema.Rows[0]["TABLE_NAME"]);
                    if (strSheetName.IndexOf(@"_xlnm#_FilterDatabase") >= 0)
                    {
                        strSheetName = Convert.ToString(dtTableSchema.Rows[1]["TABLE_NAME"]);
                    }
                }

                argQuery = argQuery + " [" + strSheetName + "]";

                OleDbCommand objCommand = new OleDbCommand(argQuery, objXConn);

                objDataAdapter.SelectCommand = objCommand;
                objDataAdapter.Fill(dsExcel);

                dtExcel = dsExcel.Tables[0];


                /*****************************************/

                DataAccess da = new DataAccess();
                da.Open_Connection();
                da.BEGIN_TRANSACTION();

                try
                {
                    foreach (DataRow drExcel in dtExcel.Rows)
                    {
                        ObjMaterialType = new MaterialType();

                        ObjMaterialType.MaterialTypeCode = Convert.ToString(drExcel["MaterialTypeCode"]).Trim();
                        ObjMaterialType.MaterialTypeDesc = Convert.ToString(drExcel["MaterialTypeDesc"]).Trim();
                        ObjMaterialType.NumRange         = Convert.ToString(drExcel["NumRange"]);
                        ObjMaterialType.RangeFrom        = Convert.ToString(drExcel["RangeFrom"]);
                        ObjMaterialType.RangeTo          = Convert.ToString(drExcel["RangeTo"]);
                        ObjMaterialType.CreatedBy        = Convert.ToString(argUserName);
                        ObjMaterialType.ModifiedBy       = Convert.ToString(argUserName);
                        ObjMaterialType.ClientCode       = Convert.ToString(argClientCode);

                        SaveMaterialType(ObjMaterialType, ref da, ref lstErr);

                        foreach (ErrorHandler objerr in lstErr)
                        {
                            if (objerr.Type == "E")
                            {
                                da.ROLLBACK_TRANSACTION();
                                break;
                            }
                        }
                    }

                    da.COMMIT_TRANSACTION();
                }
                catch (Exception ex)
                {
                    if (da != null)
                    {
                        da.ROLLBACK_TRANSACTION();
                    }
                    objErrorHandler.Type       = ErrorConstant.strAboartType;
                    objErrorHandler.MsgId      = 0;
                    objErrorHandler.Module     = ErrorConstant.strInsertModule;
                    objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
                    objErrorHandler.Message    = ex.Message.ToString();
                    objErrorHandler.RowNo      = 0;
                    objErrorHandler.FieldName  = "";
                    objErrorHandler.LogCode    = "";
                    lstErr.Add(objErrorHandler);
                }
                finally
                {
                    if (da != null)
                    {
                        da.Close_Connection();
                        da = null;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objXConn.Close();
            }

            return(lstErr);
        }
        //public ICollection<ErrorHandler> SaveMaterialType(MaterialType argMaterialType)
        //{
        //    List<ErrorHandler> lstErr = new List<ErrorHandler>();
        //    DataAccess da = new DataAccess();
        //    try
        //    {
        //        if (blnIsMaterialTypeExists(argMaterialType.MaterialTypeCode, argMaterialType.ClientCode) == false)
        //        {

        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            InsertMaterialType(argMaterialType, da, lstErr);
        //            foreach (ErrorHandler objerr in lstErr)
        //            {
        //                if (objerr.Type == "E")
        //                {
        //                    da.ROLLBACK_TRANSACTION();
        //                    return lstErr;
        //                }
        //            }

        //            da.COMMIT_TRANSACTION();
        //        }
        //        else
        //        {
        //            da.Open_Connection();
        //            da.BEGIN_TRANSACTION();
        //            UpdateMaterialType(argMaterialType, da, lstErr);
        //            foreach (ErrorHandler objerr in lstErr)
        //            {
        //                if (objerr.Type == "E")
        //                {
        //                    da.ROLLBACK_TRANSACTION();
        //                    return lstErr;
        //                }
        //            }

        //            da.COMMIT_TRANSACTION();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        if (da != null)
        //        {
        //            da.ROLLBACK_TRANSACTION();
        //        }
        //        objErrorHandler.Type = ErrorConstant.strAboartType;
        //        objErrorHandler.MsgId = 0;
        //        objErrorHandler.Module = ErrorConstant.strInsertModule;
        //        objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
        //        objErrorHandler.Message = ex.Message.ToString();
        //        objErrorHandler.RowNo = 0;
        //        objErrorHandler.FieldName = "";
        //        objErrorHandler.LogCode = "";
        //        lstErr.Add(objErrorHandler);
        //    }
        //    finally
        //    {
        //        if (da != null)
        //        {
        //            da.Close_Connection();
        //            da = null;
        //        }
        //    }
        //    return lstErr;
        //}

        // For Bulk Insert- Material Type

        public PartnerErrorResult_MM SaveMaterialType(MaterialType argMaterialType)
        {
            List <ErrorHandler>   lstErr   = new List <ErrorHandler>();
            PartnerErrorResult_MM errorcol = new PartnerErrorResult_MM();
            MaterialTypeManager   objMaterialTypeManager = new MaterialTypeManager();

            DataAccess da = new DataAccess();

            try
            {
                da.Open_Connection();
                da.BEGIN_TRANSACTION();

                objMaterialTypeManager.SaveMaterialType(argMaterialType, ref da, ref lstErr);

                foreach (ErrorHandler objerr in lstErr)
                {
                    if (objerr.Type == "E")
                    {
                        errorcol.colErrorHandler.Add(objerr);
                        da.ROLLBACK_TRANSACTION();
                        return(errorcol);
                    }

                    if (objerr.Type == "A")
                    {
                        errorcol.colErrorHandler.Add(objerr);
                        da.ROLLBACK_TRANSACTION();
                        return(errorcol);
                    }
                }

                da.COMMIT_TRANSACTION();
            }
            catch (Exception ex)
            {
                if (da != null)
                {
                    da.ROLLBACK_TRANSACTION();
                }
                objErrorHandler.Type       = ErrorConstant.strAboartType;
                objErrorHandler.MsgId      = 0;
                objErrorHandler.Module     = ErrorConstant.strInsertModule;
                objErrorHandler.ModulePart = ErrorConstant.strMasterModule;
                objErrorHandler.Message    = ex.Message.ToString();
                objErrorHandler.RowNo      = 0;
                objErrorHandler.FieldName  = "";
                objErrorHandler.LogCode    = "";
                lstErr.Add(objErrorHandler);
                errorcol.colErrorHandler.Add(objErrorHandler);
            }
            finally
            {
                if (da != null)
                {
                    da.Close_Connection();
                    da = null;
                }
            }
            return(errorcol);
        }