Exemple #1
0
        private void Form_Load(object sender, EventArgs e)
        {
            if (!SqlManager.Connect(Settings.Default.ConnectionString, false))
            {
                MessageBox.Show(Resources.Message3, Text);
                tabView_ConfigClick(sender, e);
            }

            if (SqlManager.DBinfo.conFlg == true)
            {
                SettingDBComboBox();

                if (!SqlManager.GetData(Resources.Tables, "Tables").ToBoolean() ||
                    !SqlManager.GetData(Resources.Columns, "Columns").ToBoolean())
                {
                    MessageBox.Show(Resources.Message1, Text);
                }
            }
        }
Exemple #2
0
        public bool  DeleteRolUsuario(int idusuario, int idsociedad)
        {
            SqlManager objSql    = new SqlManager();
            bool       resultado = false;
            Parameter  param     = new Parameter();

            param.Add("@idusuario", idusuario);
            param.Add("@idsociedad", idsociedad);
            try
            {
                objSql.ExecuteNonQuery("SEG_USP_Agr_Del", param);
                resultado = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resultado);
        }
Exemple #3
0
        public static EntityData GetDocumentTypeChildByParentCode(string code)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("DocumentType");
                using (SingleEntityDAO ydao = new SingleEntityDAO("DocumentType"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("DocumentType", "SelectChildByParentCode").SqlString, "@ParentCode", code, entitydata, "DocumentType");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #4
0
        public static EntityData GetDocumentIDByGroupCode(string groupcode)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("Document");
                using (SingleEntityDAO ydao = new SingleEntityDAO("Document"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("Document", "SelectByGroupCode").SqlString, "@GroupCode", groupcode, entitydata, "Document");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
        public List <UILanguage> ListarIdiomas(UILanguage objEntidad)
        {
            SqlManager        objSql = new SqlManager();
            Parameter         param  = new Parameter();
            List <UILanguage> lista  = new List <UILanguage>();

            param.Add("@IdUILanguage", objEntidad.IdUILanguage);

            try
            {
                lista = objSql.getStatement <UILanguage>("USP_listar_uilanguage", param);
            }
            catch (Exception ex) {
                throw ex;
                //afilogDAO.Save(0, 0, "UILanguageDAO", "ListarIdiomas", ex);
            }
            //Rutina de Guardado en Log
            return(lista);
        }
Exemple #6
0
        /// <summary>
        /// 批量删除分类
        /// </summary>
        /// <param name="cateids"></param>
        /// <returns></returns>
        public ResultModel DeleteCateGories(int[] cateids)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    foreach (var cateid in cateids)
                    {
                        var cateproCount = context.bsp_products.Where(t => t.cateid == cateid).Count();
                        var cate         = context.bsp_categories.SingleOrDefault(t => t.cateid == cateid);
                        if (cate == null)
                        {
                            tran.Rollback();
                            return(ResultModel.Fail($"ID为{cateid}的分类已经删除,请刷新"));
                        }
                        var sql = $@"select COUNT(bsp_cateproducts.catepid)
						    from bsp_cateproducts
						    left join bsp_products on bsp_products.pid = bsp_cateproducts.pid
						    where bsp_products.isdelete = 0 and bsp_cateproducts.cateid = {cateid}"                        ;
                        var dt  = SqlManager.FillDataTable(AppConfig.ConnectionString, new SqlCommand(sql));
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            if (int.Parse(dt.Rows[0][0].ToString()) > 0)
                            {
                                tran.Rollback();
                                return(ResultModel.Fail("分类下存在商品,不允许删除"));
                            }
                        }
                        context.bsp_categories.Remove(cate);
                        context.SaveChanges();
                    }
                    tran.Commit();
                    return(ResultModel.Success("删除成功"));
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    Logger._.Error(ex);
                    return(ResultModel.Error(ex.ToString()));
                }
            }
        }
 public List <BECargo> ListarCargos()
 {
     try
     {
         Parameter      param  = new Parameter();
         SqlManager     objSql = new SqlManager(ConfigurationManager.AppSettings["ASOCEM"].ToString());
         List <BECargo> lista  = objSql.getStatement <BECargo>("USP_Cargos_Lst", param);
         param = null;
         objSql.Dispose();
         objSql = null;
         return(lista);
     }
     catch (Exception ex)
     {
         //Rutina de Guardado en Log
         //afilogDAO.Save(0, 0, "CatalogoDAO", "GetCatalogoToCombo", ex);
         throw ex;
     }
 }
Exemple #8
0
        private DataTable GetData()
        {
            if (tbCustomeQuery.Text.IsEmpty())
            {
                var checkedCols = GetCheckedColumns();

                var checkedColumns =
                    checkedCols.Select(m => "[" + m.ToString() + "]").Aggregate((m1, m2) => m1 + "," + m2);

                var data = SqlManager.ExecuteQuery(@"select " + checkedColumns + " from " + cmbTables.Text,
                                                   tbConnectionString.Text);

                return(data);
            }
            else
            {
                return(SqlManager.ExecuteQuery(tbCustomeQuery.Text, tbConnectionString.Text));
            }
        }
Exemple #9
0
        public static EntityData GetAllDocumentType(int Fixed)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("DocumentType");
                using (SingleEntityDAO ydao = new SingleEntityDAO("DocumentType"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("DocumentType", "SelectByFixed").SqlString, "@Fixed", Fixed, entitydata, "DocumentType");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #10
0
        public List <paginaroles> RolSeleccionado(string rol, int idmenuopcion, string codigosociedad)
        {
            SqlManager         objsql  = new SqlManager();
            Parameter          param   = new Parameter();
            List <paginaroles> paginas = new List <paginaroles>();

            param.Add("@rol", rol);
            param.Add("@idmenuopcion", idmenuopcion);
            param.Add("@codigosociedad", codigosociedad);
            try
            {
                paginas = objsql.getStatement <paginaroles>("SEG_USP_RolSeleccionado", param);
                return(paginas);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #11
0
        public Boolean ValidContrasenaAlmacen(Int32 IdUsuario, String Clave)
        {
            Autorizacionusuario logeo  = new Autorizacionusuario();
            SqlManager          objSql = new SqlManager();
            Parameter           param  = new Parameter();

            param.Add("@idautorizacionusuario", IdUsuario);
            param.Add("@ContrasenaFirma", Clave);
            try
            {
                List <Autorizacionusuario> list = objSql.getStatement <Autorizacionusuario>("USP_UsuarioAutorizacion_ValidClaveFirma", param);
                return(list != null && list.Count > 0);
            }
            catch (Exception ex)
            {
                //afilogDAO.Save(0, 0, "Autorizacionusuario select empresa", "GetEmpresaByIdUsuario", ex);
                throw new Exception(ex.Message);
            }
        }
Exemple #12
0
        public List <MenuOpcion> ListarPadres()
        {
            SqlManager objSql = new SqlManager();

            Parameter         param = new Parameter();
            List <MenuOpcion> lista = new List <MenuOpcion>();

            try
            {
                lista = objSql.getStatement <MenuOpcion>("SEG_USP_MenuOpcion_LstPadres", param);
                return(lista);
            }
            catch (Exception ex)
            {
                //afilogDAO.Save(0, 0, "Autorizacionusuario validarcuenta", "validarcuenta", ex);
                throw ex;
            }
            //Rutina de Guardado en Log
        }
Exemple #13
0
        public Autorizacionusuario ObtenerUsuarioPorId(int id)
        {
            SqlManager          objSql     = new SqlManager();
            Parameter           param      = new Parameter();
            Autorizacionusuario objEntidad = new Autorizacionusuario();

            param.Add("@idautorizacionusuario", id);
            try
            {
                objEntidad = objSql.getStatement <Autorizacionusuario>("USP_obtener_autorizacionusuario", param)[0];
            }
            catch (Exception ex)
            {
                throw ex;
                //afilogDAO.Save(0, 0, "Autorizacionusuario ObtenerUsuarioPorId", "ObtenerUsuarioPorId", ex);
            }
            //Rutina de Guardado en Log
            return(objEntidad);
        }
 public List <MenuOpcion> GetMenuOpciones(string codigosociedad)
 {
     try
     {
         SqlManager objSql = new SqlManager();
         Parameter  param  = new Parameter();
         param.Add("@codigosociedad", codigosociedad);
         List <MenuOpcion> objLista = objSql.getStatement <MenuOpcion>("SEG_USP_MenuOpcion");
         param = null;
         objSql.Dispose();
         objSql = null;
         return(objLista);
     }
     catch (Exception ex)
     {
         //afilogDAO.Save(0, 0, "opcionmenuDAO", "GetMenuOpciones", ex);
         throw ex;
     }
 }
Exemple #15
0
        public static EntityData GetAllSalProjectCode()
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("Project");
                using (SingleEntityDAO ydao = new SingleEntityDAO("Project"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("Project", "SelectAllSalProjectCode").SqlString, (string[])null, (object[])null, entitydata, "Project");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #16
0
        public JsonResult DeletePropertyMap(string Id, string CategoryName)
        {
            if (Session["UserInfo"] != null)
            {
                user = (UserInfo)Session["UserInfo"];
            }

            int id = Int32.Parse(Id);

            List <SqlParameter> parameters1 = new List <SqlParameter>();

            parameters1.Add(new SqlParameter()
            {
                ParameterName = "@Id",
                SqlDbType     = SqlDbType.Int,
                Value         = id,
                Direction     = System.Data.ParameterDirection.Input
            });
            parameters1.Add(new SqlParameter()
            {
                ParameterName = "@CategoryName",
                SqlDbType     = SqlDbType.VarChar,
                Value         = CategoryName,
                Direction     = System.Data.ParameterDirection.Input
            });

            parameters1.Add(new SqlParameter()
            {
                ParameterName = "@CompId",
                SqlDbType     = SqlDbType.Int,
                Value         = user.Comp_ID,
                Direction     = System.Data.ParameterDirection.Input
            });

            DataSet dtRuleData   = SqlManager.ExecuteDataSet("SP_DeleteCategoryPropertyMapDetails", parameters1.ToArray());
            string  errormessage = "Mapping deleted successfully";

            // return Json("", "text/plain");
            return(this.Json(new DataSourceResult
            {
                Errors = errormessage
            }));
        }
Exemple #17
0
        public static EntityData GetStationByUserCode(string userCode)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("Station");
                using (SingleEntityDAO ydao = new SingleEntityDAO("Station"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("Station", "SelectByUserCode").SqlString, "@UserCode", userCode, entitydata, "Station");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #18
0
        public static EntityData GetV_ParityByPurchaseCode(string code)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("V_Parity");
                using (SingleEntityDAO ydao = new SingleEntityDAO("V_Parity"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("V_Parity", "SelectV_ParityByPurchaseCode").SqlString, "@PurchaseCode", code, entitydata, "V_Parity");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #19
0
        public static EntityData GetReceivingDetailByPurchaseDetailCode(string purchaseDetailCode)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("ReceivingDetail");
                using (SingleEntityDAO ydao = new SingleEntityDAO("ReceivingDetail"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("ReceivingDetail", "SelectReceivingDetailByPurchaseDetailCode").SqlString, "@PurchaseDetailCode", purchaseDetailCode, entitydata, "ReceivingDetail");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #20
0
        public static EntityData GetTakingDetailByTakingCode(string TakingCode)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("TakingDetail");
                using (SingleEntityDAO ydao = new SingleEntityDAO("TakingDetail"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("TakingDetail", "SelectTakingDetailByTakingCode").SqlString, "@TakingCode", TakingCode, entitydata, "TakingDetail");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #21
0
        public static EntityData GetPBSTypeLayoutByProject(string strProjectCode)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("PBSTypeLayout");
                using (SingleEntityDAO ydao = new SingleEntityDAO("PBSTypeLayout"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("PBSTypeLayout", "SelectByProjectCode").SqlString, "@ProjectCode", strProjectCode, entitydata, "PBSTypeLayout");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #22
0
        public static EntityData GetAlreadyEnquiryPurchaseDetail(string code)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("PurchaseDetail");
                using (SingleEntityDAO ydao = new SingleEntityDAO("PurchaseDetail"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("PurchaseDetail", "SelectAlreadyEnquiryPurchaseDetail").SqlString, "@purchasecode", code, entitydata, "PurchaseDetail");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Exemple #23
0
        public String GetLanguageCode(Int32 IdIdioma)
        {
            try
            {
                SqlManager objSql = new SqlManager();
                Parameter  param  = new Parameter();
                param.Add("@IdUILanguage", IdIdioma);

                String CodEmpresa = objSql.ExecuteScalar("USP_UILanguage_SelectLangCode", param).ToString();
                objSql.Dispose();
                param = null;

                return(CodEmpresa);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemple #24
0
    //返回数据库中相应的article记录(仅使用传入参数中的title字段)
    //返回一个Article的bean
    public static Article selectRecordByTitle(Article a)
    {
        string  title   = a.Title;
        string  sqlStr  = "SELECT * FROM article WHERE title='" + title + "'";
        DataSet dataset = SqlManager.GetDataSet(sqlStr, "article"); //执行查询操作

        //****************************调用这个函数的上层注意检查是否为null,如果为null说明没有查到
        if (dataset.Tables[0].Rows.Count != 0)
        {
            a.Title     = dataset.Tables[0].Rows[0]["title"].ToString();
            a.Abstrct   = dataset.Tables[0].Rows[0]["abstract"].ToString();
            a.FileURL   = dataset.Tables[0].Rows[0]["fileURL"].ToString();
            a.Time      = (DateTime)dataset.Tables[0].Rows[0]["time"];
            a.WordCount = Convert.ToInt32(dataset.Tables[0].Rows[0]["wordCount"]);
            a.Heat      = Convert.ToInt32(dataset.Tables[0].Rows[0]["heat"]);
            return(a);
        }
        return(null);
    }
    public static void Delete <T>(T businessObject, string proc = "")
    {
        Type   type               = businessObject.GetType();
        string className          = type.Name;
        string saveStoredProcName = $"usp_{className}Delete";

        if (proc != string.Empty)
        {
            saveStoredProcName = proc;
        }

        int ID = GetPrimaryKey <T>(className, businessObject);

        SqlParameter[] parameters = GetAllSqlParameter <T>(className, businessObject, false);

        SqlManager.Delete <T>(saveStoredProcName, parameters);

        return;
    }
Exemple #26
0
        public bool RegistrarCodigoElemento(UI objEntidad)
        {
            SqlManager objSql    = new SqlManager();
            bool       resultado = false;
            Parameter  param     = new Parameter();

            param.Add("@ElementCode", objEntidad.ElementCode);
            try
            {
                objSql.ExecuteNonQuery("usp_RegistrarCodigoElementoPivot_UI", param);
                resultado = true;
            }
            catch (Exception ex)
            {
                resultado = false;
            }
            //Rutina de Guardado en Log
            return(resultado);
        }
Exemple #27
0
        public List <UI> ListarElementos(UI matriz)
        {
            SqlManager objSql = new SqlManager();
            List <UI>  lista  = new List <UI>();

            try
            {
                Parameter param = new Parameter();
                param.Add("@idlanguage", matriz.IdUILanguage);
                lista = objSql.getStatement <UI>("usp_uilanguage_reader", param);
            }
            catch (Exception ex)
            {
                throw ex;
                //afilogDAO.Save( 0 ,1 , "Vista", "Listar", ex);
            }
            //Rutina de Guardado en Log
            return(lista);
        }
Exemple #28
0
        public static EntityData GetRemindStrategyByProjectCode(string code)
        {
            EntityData data2;

            try
            {
                EntityData entitydata = new EntityData("RemindStrategy");
                using (SingleEntityDAO ydao = new SingleEntityDAO("RemindStrategy"))
                {
                    ydao.FillEntity(SqlManager.GetSqlStruct("RemindStrategy", "SelectRemindStrategyByProjectCode").SqlString, "@ProjectCode", code, entitydata, "RemindStrategy");
                }
                data2 = entitydata;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
        public static Ev GetDetay(int Id)
        {
            Ev         result  = new Ev();
            SqlCommand command = new SqlCommand("spGetListEv");

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@evID", Id);
            DataSet dtSet = new SqlManager(Config.Current.MainDbConnectionString).GetDataSet(ref command);

            if (dtSet.Tables != null && dtSet.Tables.Count > 0)
            {
                DataTable dt = dtSet.Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow dtRow = dt.Rows[0];
                    result = new Ev()
                    {
                        ID            = Functions.ToInt(dtRow["evID"]),
                        EmlakTip      = dtRow["evEmlakTip"].ToString(),
                        Il            = dtRow["evIL"].ToString(),
                        Fiyat         = Functions.ToDecimal(dtRow["evFiyat"]),
                        MainResimYolu = dtRow["resimYol"].ToString()
                    };
                    if (dtSet.Tables.Count > 1)
                    {
                        dt = dtSet.Tables[1];
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            result.Resimler = new List <Resim>();
                            foreach (DataRow dtRowItem in dt.Rows)
                            {
                                result.Resimler.Add(new Resim()
                                {
                                    Yol = dtRowItem["resimYol"].ToString()
                                });
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #30
0
        public long Add(T entity)
        {
            using (var command = (_uow?.CreateCommand() ?? DbContext.Connection.CreateCommand()))
            {
                var sql = SqlManager.GetSQL($"{typeof(T).Name}_Insert");

                DbParameter[] parameters = CreateParemeters(entity, command, sql);

                foreach (var param in parameters)
                {
                    if (param.ParameterName == ":Id")
                    {
                        param.Direction = ParameterDirection.Output;
                    }
                    command.Parameters.Add(param);
                }

                command.CommandText = sql;

                command.ExecuteNonQuery();

                var parameter = command.Parameters[":Id"];

                if (parameter == null)
                {
                    return(0);
                }

                var parameterType = parameter.GetType();


                var id = parameterType.GetProperty("Value").GetValue(parameter); //command.Parameters[":Id"].ToString();

                if (id != null)
                {
                    return(Convert.ToInt64(id));
                }


                return(0);
            }
        }