Esempio n. 1
0
        /// <summary>
        /// 判断用户登录
        /// </summary>
        /// <param name="sCode"></param>  编号
        /// <param name="sUser"></param>  用户名
        /// <param name="sPass"></param>  密码
        /// <param name="dba"></param>    数据库操作
        /// <returns></returns>           返回查询结果值
        public int loginJudge(string sCode, string sUser, string sPass, dbAccess dba)
        {
            String sLog = "Select count(1) as usercount from users where user_code ='"
                          + sCode + "' and user_detail = '" + sUser
                          + "' and user_pwd = '" + sPass + "'";

            return(Convert.ToInt32(getQueryResultBySQL(sLog)));
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            serverini      = new IniFiles(@Application.StartupPath + "\\Config.ini");
            FirstLocaltion = serverini.ReadValue("ResourceCodeParam", "FirstLocaltion");
            Benindregion   = serverini.ReadValue("ResourceCodeParam", "Benindregion");

            dba = new dbAccess();
            dba.conn.ConnectionString = GetConnectString();

            dd = new List <OrganizationItem>();
        }
Esempio n. 3
0
        /// <summary>
        /// 更新或新增记录  特殊用法
        /// </summary>
        /// <param name="sTable"></param>      表名
        /// <param name="sColValTye"></param>  字符串数组,组成方式为 “字段名,值,字段类型”
        /// <param name="sWhere"></param>      更新条件
        /// <param name="dba"></param>         数据库处理对象
        /// <returns></returns>                返回值,成功1、失败-1
        public static int UpdateOrInsert(string sTable, int iMode, List <string> sColValTye, string sWhere, dbAccess dba)
        {
            try
            {
                string   sSql = "", sSql2 = "", sTmp = "";
                string[] strTmp;
                if (iMode == 1) //新增
                {
                    for (int i = 0; i < sColValTye.Count; i++)
                    {
                        if (sColValTye[i] == null || sColValTye[i].Length == 0)
                        {
                            continue;
                        }
                        strTmp = sColValTye[i].Split(',');
                        if (strTmp.Length == 3)
                        {
                            if (strTmp[2].ToLower() == "string")
                            {
                                sSql  += strTmp[0] + ",";
                                sSql2 += "'" + strTmp[1] + "',";
                            }
                            else if (strTmp[2].ToLower() == "datetime")
                            {
                                sSql  += strTmp[0] + ",";
                                sSql2 += "cast('" + strTmp[1] + "' as datetime),";
                            }
                            else if (strTmp[2].ToLower() == "int")
                            {
                                sSql  += strTmp[0] + ",";
                                sSql2 += strTmp[1] + ",";
                            }
                        }
                        else if (strTmp.Length > 3)
                        {
                            sTmp = "";
                            for (int j = 1; j < strTmp.Length - 1; j++)
                            {
                                sTmp = sTmp + strTmp[j] + ",";
                            }
                            sTmp = sTmp.TrimEnd(',');
                            if (strTmp[strTmp.Length - 1].ToLower() == "string")
                            {
                                sSql  += strTmp[0] + ",";
                                sSql2 += "'" + sTmp + "',";
                            }
                            else if (strTmp[strTmp.Length - 1].ToLower() == "datetime")
                            {
                                sSql  += strTmp[0] + ",";
                                sSql2 += "cast('" + strTmp[1] + "' as datetime),";
                            }
                            else if (strTmp[strTmp.Length - 1].ToLower() == "int")
                            {
                                sSql  += strTmp[0] + ",";
                                sSql2 += sTmp + ",";
                            }
                        }
                    }
                    if (sSql.Length > 0)
                    {
                        sSql  = sSql.TrimEnd(',');
                        sSql2 = sSql2.TrimEnd(',');
                        sSql  = "Insert into " + sTable + "(" + sSql + ") values (" + sSql2 + ")";
                    }
                }
                else if (iMode == 2) //修改
                {
                    for (int i = 0; i < sColValTye.Count; i++)
                    {
                        if (sColValTye[i] == null || sColValTye[i].Length == 0)
                        {
                            continue;
                        }
                        strTmp = sColValTye[i].Split(',');

                        if (strTmp.Length == 3)
                        {
                            if (strTmp[2].ToLower() == "string")
                            {
                                sSql += strTmp[0] + " = '" + strTmp[1] + "',";
                            }
                            else if (strTmp[2].ToLower() == "datetime")
                            {
                                sSql += strTmp[0] + " = cast('" + strTmp[1] + "' as datetime),";
                            }
                            else if (strTmp[2].ToLower() == "int")
                            {
                                sSql += strTmp[0] + " = " + strTmp[1] + ",";
                            }
                        }
                        else if (strTmp.Length > 3)
                        {
                            sTmp = "";
                            for (int j = 1; j < strTmp.Length - 1; j++)
                            {
                                sTmp = sTmp + strTmp[j] + ",";
                            }
                            sTmp = sTmp.TrimEnd(',');
                            if (strTmp[strTmp.Length - 1].ToLower() == "string")
                            {
                                sSql += strTmp[0] + " = '" + sTmp + "',";
                            }
                            else if (strTmp[strTmp.Length - 1].ToLower() == "datetime")
                            {
                                sSql += strTmp[0] + " = cast('" + strTmp[1] + "' as datetime),";
                            }
                            else if (strTmp[strTmp.Length - 1].ToLower() == "int")
                            {
                                sSql += strTmp[0] + " = " + sTmp + ",";
                            }
                        }
                    }
                    if (sSql.Length > 0)
                    {
                        sSql = sSql.TrimEnd(',');
                        sSql = "Update " + sTable + " Set " + sSql + (sWhere.Length > 0 ? sWhere : "");
                    }
                }
                if (sSql.Length > 0 && dba.UpdateDbBySQL(sSql) != 1)
                {
                    return(-1);
                }
            }
            catch
            {
                return(-1);
            }
            return(1);
        }