Example #1
0
        public HandlingResult Update(SnModel model)
        {
            HandlingResult result = new HandlingResult();
             String sql = String.Format("UPDATE BPSYS_STORESN SET NAME='{0}',CODE='{1}' WHERE ID='{2}'", model.Name,
                 model.Code, model.Id);
             String querysql = String.Format("SELECT ID FROM BPSYS_STORESN WHERE CODE='{0}'", model.Code);

             using (DataBaseProcess process = new DataBaseProcess())
             {
                 DataTable dt = process.Query(querysql);
                 if (dt != null && dt.Rows.Count > 0)
                 {
                     Guid id = Guid.Parse(dt.Rows[0]["ID"].ToString());
                     if (id != model.Id)
                     {

                         result.MsgNumber = 0;
                         result.Message = String.Format("SN[{0}]已经存在", model.Code);
                     }
                     else
                     {
                         result.MsgNumber = process.Exec(sql);
                     }
                 }
             }
             result.Successed = result.MsgNumber > 0;
             result.Message = result.Message.Length > 0 ? result.Message : result.Successed ? "更新成功" : "更新失败";
             return result;
        }
Example #2
0
 public HandlingResult Add(SnModel model)
 {
     HandlingResult result = new HandlingResult();
      String querysql = String.Format("SELECT COUNT(1) AS CNT FROM BPSYS_STORESN WHERE CODE='{0}'", model.Code);
      String sql =
          "INSERT INTO BPSYS_STORESN(ID, STOREID, NAME, CODE, STATUS, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}', '{2}', '{3}', {4}, '{5}', '{6}', '{7}')";
      sql = String.Format(sql, model.Id, model.StoreId, model.Name, model.Code, 1,
          UserInformationContext.LoginName,
          UserInformationContext.ID, DateTime.Now.ToString(ConfigImformationContext.TIME_FORMAT_FULL));
      using (DataBaseProcess process = new DataBaseProcess())
      {
          DataTable dt = process.Query(querysql);
          if (dt != null && dt.Rows.Count > 0)
          {
              result.MsgNumber = Int32.Parse(dt.Rows[0]["CNT"].ToString());
              if (result.MsgNumber == 0)
              {
                  result.MsgNumber = process.Exec(sql);
              }
              else
              {
                  result.MsgNumber = 0;
                  result.Message = String.Format("SN[{0}]已经存在", model.Code);
              }
          }
      }
      result.Successed = result.MsgNumber > 0;
      result.Message = result.Successed ? "新增成功" : "新增失败";
      return result;
 }
Example #3
0
 public DataTable Query()
 {
     String sql = "SELECT ID, NAME,PHONE FROM BPSYS_STORE";
     DataTable dt=new DataTable();
     using (DataBaseProcess process=new DataBaseProcess())
     {
         dt= process.Query(sql);
     }
     return dt;
 }
Example #4
0
 public DataTable QueryByStore(Guid storeId)
 {
     String sql =String.Format("SELECT ID,CODE,NAME FROM BPSYS_STORESN WHERE STOREID='{0}'",storeId);
     DataTable dt = null;
     using (DataBaseProcess process=new DataBaseProcess())
     {
         dt = process.Query(sql);
     }
     return dt;
 }
Example #5
0
 public DataTable GetList(String sourceName)
 {
     String sql =String.Format("SELECT T.ID, T.CODE FROM BPSYS_DATADICDETAIL T INNER JOIN BPSYS_DATADIC D ON T.SOURCE=D.ID AND D.CODE='{0}'",sourceName);
     DataTable dt = null;
     using (DataBaseProcess process = new DataBaseProcess())
     {
         dt = process.Query(sql);
     }
     return dt;
 }
Example #6
0
 public DataTable GetDicList()
 {
     String sql = "SELECT ID, CODE FROM BPSYS_DATADIC";
     DataTable dt = null;
     using (DataBaseProcess process = new DataBaseProcess())
     {
         dt = process.Query(sql);
     }
     return dt;
 }
Example #7
0
 public DataTable GetList()
 {
     String sql =
         "SELECT T.CODE, T.ID, D.CODE AS DCODE FROM BPSYS_DATADIC D INNER JOIN BPSYS_DATADICDETAIL T ON D.ID = T.SOURCE";
     DataTable dt = null;
     using (DataBaseProcess process = new DataBaseProcess())
     {
         dt = process.Query(sql);
     }
     return dt;
 }
Example #8
0
 public DataTable GetSchema(String schemaName)
 {
     String sql = String.Format("SELECT * FROM {0} WHERE 1=2", schemaName);
     DataTable dt = null;
     using (DataBaseProcess process = new DataBaseProcess())
     {
         dt = process.Query(sql);
         dt.TableName = schemaName;
     }
     return dt;
 }
Example #9
0
 public DataSet GetSchema(List<String> schemaNameList)
 {
     String sql = "SELECT * FROM {0} WHERE 1=2";
     DataSet ds = new DataSet();
     String schsql = "";
     using (DataBaseProcess process = new DataBaseProcess())
     {
         foreach (var schema in schemaNameList)
         {
             schsql = String.Format(sql, schema);
             DataTable dt = process.Query(sql);
             if (dt != null)
             {
                 dt.TableName = schema;
                 ds.Tables.Add(dt);
             }
         }
     }
     return ds;
 }
Example #10
0
 public HandlingResult Add(UserModel model)
 {
     HandlingResult result=new HandlingResult();
     result.Successed = false;
     if (model != null)
     {
         String querysql =String.Format("SELECT COUNT(1) AS CNT FROM BPSYS_USER WHERE LOGINNAME='{0}'",model.LoginName);
         String sql =
             String.Format(
                 "INSERT INTO BPSYS_USER(ID, LOGINNAME, NAME, PASSWORD, PHONE, STOREID, STATUS, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, '{7}', '{8}', '{9}')",
                 model.Id, model.LoginName, model.Name, model.Password, model.Phone, model.StoreId, 1,
                 UserInformationContext.LoginName, UserInformationContext.ID,
                 DateTime.Now.ToString(ConfigImformationContext.TIME_FORMAT_FULL));
         using (DataBaseProcess process=new DataBaseProcess())
         {
             DataTable dt = process.Query(querysql);
             if (dt != null && dt.Rows.Count > 0)
             {
                 result.MsgNumber = Int32.Parse(dt.Rows[0]["CNT"].ToString());
                 if (result.MsgNumber == 0)
                 {
                     result.MsgNumber = process.Exec(sql);
                 }
                 else
                 {
                     result.MsgNumber = 0;
                     result.Message = String.Format("用户[{0}]已经存在", model.LoginName);
                 }
             }
         }
     }
     result.Successed = result.MsgNumber > 0;
     if (String.IsNullOrEmpty(result.Message))
     {
         result.Message = result.Successed ? "新增成功" : "新增失败";
     }
     return result;
 }
 public HandlingResult ValidateLogin(UserValidationModel model)
 {
     HandlingResult result=new HandlingResult();
     result.Successed = false;
     DataTable dt = null;
     String sql = String.Format("SELECT * FROM BPSYS_USER WHERE LOGINNAME='{0}'", model.LoginName);
     using (DataBaseProcess process = new DataBaseProcess())
     {
         dt = process.Query(sql);
     }
     if (dt != null && dt.Rows.Count > 0)
     {
         UserInformationModel usermodel = new UserInformationModel()
         {
             Id = Guid.Parse(dt.Rows[0]["ID"].ToString()),
             LoginName = dt.Rows[0]["LOGINNAME"].ToString(),
             Name = dt.Rows[0]["NAME"].ToString(),
             StoreId = dt.Rows[0]["STOREID"].ToString(),
         };
         String pw = Md5Helper.GetMD5String(model.Password);
         if (pw.Equals(dt.Rows[0]["PASSWORD"].ToString()))
         {
             result.Result = usermodel;
             result.Successed = true;
         }
         else
         {
             result.Message = "用户名或密码错误!";
         }
     }
     else
     {
         result.Message = "用户名或密码错误";
     }
     return result;
 }
        public DataTable Query(DetailReportQueryModel model)
        {
            String sql =
                "SELECT B.ID, B.SN, B.RUNNINGNO, B.EXCTIME, B.EXCSOURCE, B.NETPAY,B.PAYABLE, B.HANDLING, B.STATUE, B.BANKRUNNINGNO FROM `BUSINESS_TRANSFLOW` B ";
            if (model.StoreId != null && model.StoreId!=Guid.Empty.ToString())
            {
                sql += String.Format(
                    " INNER JOIN `BPSYS_STORESN` N ON B.`SN`= N.`CODE` " +
                    " INNER JOIN `BPSYS_STORE` S ON S.`ID`= N.`STOREID` " +
                    " WHERE 1=1 AND S.`ID`= '{0}' ", model.StoreId);
                if (!String.IsNullOrEmpty(model.SN))
                {
                    sql += String.Format(" AND N.CODE='{0}'", model.SN);
                }
            }
            else
            {
                sql += " WHERE 1=1 ";
            }
            if (!String.IsNullOrEmpty(model.Source))
            {
                sql += String.Format(" AND B.EXCSOURCE='{0}'", model.Source);
            }
            if (model.StartTime.HasValue && model.FinishTime.HasValue)
            {
                sql += String.Format(" AND B.EXCTIME BETWEEN '{0}' AND '{1}' ",
                    model.StartTime.Value.ToString(TIME_FORMAT), model.FinishTime.Value.ToString(TIME_FORMAT));
            }
            DataTable dt = new DataTable();
            using (DataBaseProcess process=new DataBaseProcess())
            {
                dt = process.Query(sql);
            }

            return dt;
        }
        public HandlingResult Query(SummaryReportQueryModel queryModel)
        {
            HandlingResult result=new HandlingResult();
            //SELECT SUM(NETPAY)AS NETPAY, SUM(PAYABLE) AS NETPAY, SUM(HANDLING) AS NETPAY, EXCSOURCE
            //FROM   BUSINESS_TRANSFLOW
            //WHERE  SN = '' AND EXCTIME BETWEEN '' AND ''
            //GROUP  BY EXCSOURCE

            //SELECT EXCSOURCE, NETPAY, PAYABLE, HANDLING
            //FROM   BUSINESS_TRANSFLOW
            //WHERE  SN = '' AND EXCTIME BETWEEN '' AND ''

            //SELECT SUM(NETPAY) AS NETPAY, SUM(PAYABLE) AS NETPAY, SUM(HANDLING) AS NETPAY, EXCSOURCE, SN
            //FROM   BUSINESS_TRANSFLOW
            //WHERE  EXCTIME BETWEEN '' AND ''
            //GROUP  BY SN, EXCSOURCE
            StringBuilder cntsqlbuilder = new StringBuilder(" SELECT COUNT(1) AS CNT FROM BUSINESS_TRANSFLOW T ");

            cntsqlbuilder.Append(" INNER JOIN BPSYS_STORESN N ON T.SN=N.CODE ");
            cntsqlbuilder.Append(" INNER JOIN BPSYS_STORE S ON S.ID=N.STOREID ");
            cntsqlbuilder.Append(" WHERE 1=1 ");
            if (queryModel.StartTime.HasValue && queryModel.FinishTime.HasValue)
            {
                cntsqlbuilder.AppendFormat(" AND T.EXCTIME BETWEEN '{0}' AND '{1}' ",
                        queryModel.StartTime.Value.ToString(TIME_FORMAT),
                        queryModel.FinishTime.Value.ToString(TIME_FORMAT));
            }
            if (!String.IsNullOrEmpty(queryModel.SN))
            {
                cntsqlbuilder.AppendFormat(" AND T.SN='{0}' ", queryModel.SN);
            }
            else
            {
                if (!String.IsNullOrEmpty(queryModel.SNName))
                {
                    cntsqlbuilder.AppendFormat(" AND N.NAME='{0}' ",
                        queryModel.SNName);
                }
            }
            if (queryModel.StoreId != null && queryModel.StoreId != Guid.Empty)
            {
                cntsqlbuilder.AppendFormat(" AND S.ID='{0}' ", queryModel.StoreId);
            }
            if (!String.IsNullOrEmpty(queryModel.Source))
            {
                cntsqlbuilder.AppendFormat("  AND T.EXCSOURCE='{0}' ", queryModel.Source);
            }

            StringBuilder sqlbulider=new StringBuilder();
            if (queryModel.ReportType == 1)
            {
                //明细
                sqlbulider.Append(" SELECT SN,STATUE,BANKRUNNINGNO,EXCTIME,EXCSOURCE, NETPAY, PAYABLE, HANDLING FROM   BUSINESS_TRANSFLOW T");
                sqlbulider.Append(" INNER JOIN BPSYS_STORESN N ON T.SN=N.CODE ");
                sqlbulider.Append(" INNER JOIN BPSYS_STORE S ON S.ID=N.STOREID ");
                sqlbulider.Append(" WHERE 1=1 ");
                if (!String.IsNullOrEmpty(queryModel.SN))
                {
                    sqlbulider.AppendFormat(" AND T.SN='{0}'", queryModel.SN);
                }
                else
                {
                    if (!String.IsNullOrEmpty(queryModel.SNName))
                    {
                        sqlbulider.AppendFormat(" AND N.NAME='{0}' ", queryModel.SNName);
                    }
                }
                if (queryModel.StartTime.HasValue && queryModel.FinishTime.HasValue)
                {
                    sqlbulider.AppendFormat(" AND EXCTIME BETWEEN '{0}' AND '{1}'",
                        queryModel.StartTime.Value.ToString(TIME_FORMAT),
                        queryModel.FinishTime.Value.ToString(TIME_FORMAT));
                }
                if (queryModel.StoreId != null && queryModel.StoreId != Guid.Empty)
                {
                    sqlbulider.AppendFormat(" AND S.ID='{0}' ", queryModel.StoreId);
                }
                if (!String.IsNullOrEmpty(queryModel.Source))
                {
                    sqlbulider.AppendFormat("  AND EXCSOURCE='{0}'", queryModel.Source);
                }

            }
            else
            {
                //汇总
                if (String.IsNullOrEmpty(queryModel.SN))
                {
                    //所有SN汇总
                    sqlbulider.Append("SELECT SUM(NETPAY) AS NETPAY, SUM(PAYABLE) AS PAYABLE, SUM(HANDLING) AS HANDLING, EXCSOURCE, SN FROM   BUSINESS_TRANSFLOW T ");
                    sqlbulider.Append(" INNER JOIN BPSYS_STORESN N ON T.SN=N.CODE ");
                    sqlbulider.Append(" INNER JOIN BPSYS_STORE S ON S.ID=N.STOREID ");
                    sqlbulider.Append(" WHERE 1=1 ");
                    if (queryModel.StartTime.HasValue && queryModel.FinishTime.HasValue)
                    {
                        sqlbulider.AppendFormat(" AND T.EXCTIME BETWEEN '{0}' AND '{1}'",
                            queryModel.StartTime.Value.ToString(TIME_FORMAT),
                            queryModel.FinishTime.Value.ToString(TIME_FORMAT));
                    }
                    if (!String.IsNullOrEmpty(queryModel.SNName))
                    {
                        sqlbulider.AppendFormat(" AND N.NAME='{0}' ", queryModel.SNName);
                    }
                    if (queryModel.StoreId != null && queryModel.StoreId != Guid.Empty)
                    {
                        sqlbulider.AppendFormat(" AND S.ID='{0}' ", queryModel.StoreId);
                    }
                    if (!String.IsNullOrEmpty(queryModel.Source))
                    {
                        sqlbulider.AppendFormat("  AND T.EXCSOURCE='{0}'", queryModel.Source);
                    }
                    sqlbulider.Append(" GROUP  BY T.SN, T.EXCSOURCE");
                }
                else
                {
                    //单独SN汇总
                    sqlbulider.Append("SELECT SUM(NETPAY) AS NETPAY, SUM(PAYABLE) AS PAYABLE, SUM(HANDLING) AS HANDLING, EXCSOURCE FROM   BUSINESS_TRANSFLOW T ");
                    sqlbulider.Append(" INNER JOIN BPSYS_STORESN N ON T.SN=N.CODE ");
                    sqlbulider.Append(" INNER JOIN BPSYS_STORE S ON S.ID=N.STOREID ");
                    sqlbulider.Append(" WHERE 1=1 ");
                    if (queryModel.StartTime.HasValue && queryModel.FinishTime.HasValue)
                    {
                        sqlbulider.AppendFormat(" AND T.EXCTIME BETWEEN '{0}' AND '{1}'",
                            queryModel.StartTime.Value.ToString(TIME_FORMAT),
                            queryModel.FinishTime.Value.ToString(TIME_FORMAT));
                    }
                    sqlbulider.AppendFormat(" AND T.SN='{0}'", queryModel.SN);
                    if (queryModel.StoreId != null && queryModel.StoreId != Guid.Empty)
                    {
                        sqlbulider.AppendFormat(" AND S.ID='{0}' ", queryModel.StoreId);
                    }
                    if (!String.IsNullOrEmpty(queryModel.Source))
                    {
                        sqlbulider.AppendFormat("  AND T.EXCSOURCE='{0}'", queryModel.Source);
                    }
                    sqlbulider.Append(" GROUP  BY T.EXCSOURCE");
                }
            }
            using (DataBaseProcess process = new DataBaseProcess())
            {
                DataTable dtcnt = process.Query(cntsqlbuilder.ToString());
                if (dtcnt != null && dtcnt.Rows.Count > 0)
                {
                    Int32 i = 0;
                    Int32.TryParse(dtcnt.Rows[0]["CNT"].ToString(), out i);
                    result.MsgNumber = i;
                }
                DataTable dt = process.Query(sqlbulider.ToString());
                result.Result = dt;
            }
            return result;
        }
Example #14
0
 public DataTable GetList(UserQueryModel model)
 {
     DataTable dt = null;
     if (model != null)
     {
         String sql = "SELECT U.ID, U.LOGINNAME, U.NAME, U.PHONE, U.STATUS,CASE U.STATUS WHEN 1 THEN '有效' ELSE '无效' END AS STA, S.NAME AS SNAME,U.PASSWORD,U.STOREID FROM BPSYS_USER U INNER JOIN BPSYS_STORE S ON U.STOREID = S.ID";
         sql += " WHERE 1=1";
         //where u.[Name] like '%%' or u.Phone ='' or s.[Name] like '%%'
         if (!String.IsNullOrEmpty(model.Name))
         {
             sql += String.Format(" AND U.NAME LIKE '%{0}%'", model.Name);
         }
         if (!String.IsNullOrEmpty(model.Phone))
         {
             sql += String.Format(" AND U.PHONE ='{0}'", model.Phone);
         }
         if (model.Store != null && model.Store != Guid.Empty)
         {
             sql += String.Format(" AND S.ID='{0}'", model.Store.ToString());
         }
         using (DataBaseProcess process=new DataBaseProcess())
         {
             dt = process.Query(sql);
         }
     }
     return dt;
 }