Пример #1
0
        public List <HCM_Area> GetAreaByModuleID(int ModuleID)
        {
            List <HCM_Area> area_list = new List <HCM_Area>();
            HCM_Area        area_obj  = new HCM_Area();

            try
            {
                using (SqlConnection sql_obj = new SqlConnection())
                {
                    sql_obj.ConnectionString = sql.GetConnection();
                    sql_obj.Open();
                    using (SqlCommand cmd = new SqlCommand("HCM_PROC_GetAreaByModuleID", sql_obj))
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandTimeout = 0;
                        if (ModuleID != null)
                        {
                            cmd.Parameters.AddWithValue("@ModuleID", ModuleID);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@ModuleID", DBNull.Value);
                        }
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        sql_obj.Close();
                        if (dt.Rows.Count > 0)
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                area_obj          = new HCM_Area();
                                area_obj.AreaID   = Convert.ToInt32(dt.Rows[i]["AreaID"]);
                                area_obj.AreaName = Convert.ToString(dt.Rows[i]["AreaName"]);
                                area_list.Add(area_obj);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(area_list);
        }
Пример #2
0
        public List <HCM_Area> GetAllreas()
        {
            List <HCM_Area> hcm_AreaList_Obj = new List <HCM_Area>();
            HCM_Area        hcm_Areas_Obj    = new HCM_Area();

            try
            {
                using (SqlConnection sqlcon_Obj = new SqlConnection())
                {
                    sqlcon_Obj.ConnectionString = con.GetConnection();
                    sqlcon_Obj.Open();
                    using (SqlCommand sqlcmd_Obj = new SqlCommand("HCM_PROC_GetAreasList", sqlcon_Obj))
                    {
                        sqlcmd_Obj.CommandTimeout = 0;
                        sqlcmd_Obj.CommandType    = CommandType.StoredProcedure;
                        SqlDataAdapter da = new SqlDataAdapter(sqlcmd_Obj);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        sqlcon_Obj.Close();

                        if (dt.Rows.Count > 0)
                        {
                            for (var i = 0; i < dt.Rows.Count; i++)
                            {
                                hcm_Areas_Obj = new HCM_Area();
                                hcm_Areas_Obj.Product.ProductID   = dt.Rows[i]["ProductID"] == DBNull.Value ? (int?)null: Convert.ToInt32(dt.Rows[i]["ProductID"]);
                                hcm_Areas_Obj.Product.ProductName = Convert.ToString(dt.Rows[i]["ProductName"]);
                                hcm_Areas_Obj.AreaID            = Convert.ToInt32(dt.Rows[i]["AreaID"]);
                                hcm_Areas_Obj.Module.ModuleID   = Convert.ToInt32(dt.Rows[i]["ModuleID"]);
                                hcm_Areas_Obj.Module.ModuleName = Convert.ToString(dt.Rows[i]["ModuleName"]);
                                hcm_Areas_Obj.AreaName          = Convert.ToString(dt.Rows[i]["AreaName"]);
                                hcm_Areas_Obj.AreaDescription   = Convert.ToString(dt.Rows[i]["AreaDescription"]);
                                hcm_Areas_Obj.Status            = Convert.ToBoolean(dt.Rows[i]["Status"]);
                                hcm_Areas_Obj.CreatedOn         = Convert.ToDateTime(dt.Rows[i]["CreatedOn"]);
                                hcm_AreaList_Obj.Add(hcm_Areas_Obj);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(hcm_AreaList_Obj);
        }