Пример #1
0
        public HandlingResult Clear(ReportClearModel model)
        {
            HandlingResult result=new HandlingResult();
            Boolean wherecluse = false;
            //            SELECT F.*FROM BUSINESS_TRANSFLOW F
            //INNER
            //                      JOIN BPSYS_STORESN SN ON SN.CODE = F.RUNNINGNO
            //                INNER
            //                      JOIN BPSYS_STORE S ON S.ID = SN.STOREID
            //WHERE F.EXCTIME BETWEEN '2015-11-30 17:00:00'  AND '2015-12-01 19:00:00'
            //AND F.SN = '89'
            //AND F.EXCSOURCE = '微信'
            //AND SN.NAME = '子店1'
            //AND S.ID = ''
            String delsql = " DELETE FROM BUSINESS_TRANSFLOW WHERE EXISTS ";
            String insertsql = " INSERT INTO BUSINESS_TRANSFLOWT ";
            String closql=" SELECT F.* FROM BUSINESS_TRANSFLOW F ";
            closql += " INNER JOIN BPSYS_STORESN SN ON SN.CODE = F.RUNNINGNO ";
            closql += " INNER JOIN BPSYS_STORE S ON S.ID = SN.STOREID ";
            closql += " WHERE 1=1 ";
            if (model.StoreId != null && model.StoreId != Guid.NewGuid())
            {
                closql += String.Format(" AND S.ID='{0}' ",model.StoreId);
            }

            if (model.StartTime.HasValue && model.FinishTime.HasValue)
            {
                closql += String.Format(" AND F.EXCTIME BETWEEN '{0}'  AND '{1}'",
                    model.StartTime.Value.ToString(TIME_FORMAT), model.FinishTime.Value.ToString(TIME_FORMAT));
            }
            if (!String.IsNullOrEmpty(model.SN))
            {
                closql += String.Format("  F.SN={0}",model.SN);
            }
            if (!String.IsNullOrEmpty(model.SNName))
            {
                closql += String.Format("  SN.NAME={0}", model.SNName);
            }
            if (!String.IsNullOrEmpty(model.Source))
            {
                closql += String.Format("  F.EXCSOURCE={0}", model.Source);
            }
            insertsql += closql;
            delsql += string.Format("(SELECT 1 FROM ( {0} ) T WHERE BUSINESS_TRANSFLOW.ID=T.ID)", closql);
            using (DataBaseProcess process=new DataBaseProcess())
            {
                result.MsgNumber= process.Exec(insertsql);
                result.MsgNumber=process.Exec(delsql);
            }
            result.Successed = result.MsgNumber > 0;
            return result;
        }
Пример #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;
 }
Пример #3
0
 public void ChangePassword(Guid userId,String password)
 {
     String secpw = Md5Helper.GetMD5String(password);
     String sql = String.Format("update bpsys_user set password='******' where id='{1}'", secpw, userId);
     using (DataBaseProcess process = new DataBaseProcess())
     {
         process.Exec(sql);
     }
 }
Пример #4
0
 public HandlingResult Update(StoreModel model)
 {
     HandlingResult result = new HandlingResult();
     String sql = String.Format("UPDATE BPSYS_STORE SET NAME='{0}', PHONE='{1}' WHERE ID='{2}'",model.Name,model.Phone,model.Id);
     using (DataBaseProcess process = new DataBaseProcess())
     {
         result.MsgNumber = process.Exec(sql);
     }
     result.Successed = result.MsgNumber > 0;
     result.Message = result.Successed ? "更新成功" : "更新失败";
     return result;
 }
Пример #5
0
 public HandlingResult Delete(Guid userId)
 {
     HandlingResult result = new HandlingResult();
     String sql = string.Format("UPDATE BPSYS_USER SET STATUS=2' WHERE ID='{0}'", userId);
     using (DataBaseProcess process = new DataBaseProcess())
     {
         result.MsgNumber = process.Exec(sql);
     }
     result.Successed = result.MsgNumber > 0;
     result.Message = result.Successed ? "修改成功" : "修改失败";
     return result;
 }
Пример #6
0
 public HandlingResult Add(StoreModel model)
 {
     HandlingResult result=new HandlingResult();
     String sql =
         "INSERT INTO BPSYS_STORE(ID, NAME, PHONE, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')";
     sql = String.Format(sql, model.Id, model.Name, model.Phone, UserInformationContext.LoginName,
         UserInformationContext.ID, DateTime.Now.ToString(ConfigImformationContext.TIME_FORMAT_FULL));
     using (DataBaseProcess process=new DataBaseProcess())
     {
         result.MsgNumber= process.Exec(sql);
     }
     result.Successed = result.MsgNumber > 0;
     result.Message = result.Successed ? "新增成功" : "新增失败";
     return result;
 }
Пример #7
0
 public HandlingResult Add(DataDicDetailModel model)
 {
     HandlingResult result=new HandlingResult();
     result.Successed = false;
     if (model != null)
     {
         String sql =
             String.Format(
                 "INSERT INTO BPSYS_DATADICDETAIL(ID, CODE, SOURCE, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}','{2}' , '{3}','{4}','{5}')",
                 model.Id, model.Code, model.Source, UserInformationContext.LoginName, UserInformationContext.ID,
                 DateTime.Now.ToString(ConfigImformationContext.TIME_FORMAT_FULL));
         using (DataBaseProcess process = new DataBaseProcess())
         {
             result.MsgNumber = process.Exec(sql);
         }
     }
     result.Successed = result.MsgNumber > 0;
     result.Message = result.Successed ? "新增成功" : "新增失败";
     return result;
 }
Пример #8
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;
 }
Пример #9
0
 public HandlingResult Modify(UserModel model)
 {
     HandlingResult result = new HandlingResult();
     result.Successed = false;
     if (model != null)
     {
         String sql =
             String.Format(
                 "UPDATE BPSYS_USER SET LOGINNAME='{0}', NAME='{1}', PHONE='{2}', STOREID='{3}' WHERE ID='{4}'",
                 model.LoginName,model.Name,model.Phone,model.StoreId,model.Id );
         using (DataBaseProcess process = new DataBaseProcess())
         {
             result.MsgNumber = process.Exec(sql);
         }
     }
     result.Successed = result.MsgNumber > 0;
     result.Message = result.Successed ? "修改成功" : "修改失败";
     return result;
 }
Пример #10
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;
        }
        public HandlingResult Import(DataTable source)
        {
            //机器SN号	交易时间	交易流水号	交易来源	实付金额	应付金额	手续费	状态	银行流水单
            HandlingResult result = new HandlingResult();
            SchemaAction action = new SchemaAction();
            DataTable dt = action.GetSchema("BUSINESS_TRANSFLOWCP");
            Guid id = Guid.NewGuid();
            DateTime t = DateTime.Now;
            foreach (DataRow sdr in source.Rows)
            {
                try
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"] = Guid.NewGuid();
                    dr["SN"] = sdr["机器SN号"];
                    dr["RunningNo"] = sdr["交易流水号"];
                    dr["ExcTime"] = sdr["交易时间"];
                    dr["ExcSource"] = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(sdr["交易来源"].ToString()));
                    dr["NetPay"] = sdr["实付金额"];
                    dr["Payable"] = sdr["应付金额"];
                    dr["Handling"] = sdr["手续费"];
                    dr["Statue"] = sdr["状态"];
                    dr["BankRunningNo"] = sdr["银行流水单"];
                    dr["BID"] = id;
                    dr["Creator"] = UserInformationContext.LoginName;
                    dr["CreatorID"] = UserInformationContext.ID;
                    dr["CreatedTime"] = t;
                    dt.Rows.Add(dr);
                }
                catch (Exception ex)
                {
                    continue;
                }
            }
            String sql = "SELECT * FROM BUSINESS_TRANSFLOWCP WHERE 1=2";

            String insertsql = String.Format(
                "INSERT INTO  BUSINESS_TRANSFLOW  " +
                "SELECT C.ID,C.SN,C.RUNNINGNO,C.EXCTIME,C.EXCSOURCE,C.NETPAY,C.PAYABLE,C.HANDLING, " +
                "C.STATUE,C.BANKRUNNINGNO,C.CREATOR, C.CREATORID, C.CREATEDTIME " +
                "FROM   BUSINESS_TRANSFLOWCP C LEFT OUTER JOIN BUSINESS_TRANSFLOW S ON C.RUNNINGNO = S.RUNNINGNO " +
                "WHERE  C.BID='{0}' AND S.RUNNINGNO IS NULL", id);
            String delsql = String.Format("delete from business_transflowcp where bid='{0}'", id);
            using (DataBaseProcess process =new DataBaseProcess())
            {
                try
                {
                    Boolean upresult = process.Update(dt, sql);
                    if (upresult)
                    {
                        process.Exec(insertsql);
                        process.Exec(delsql);
                        result.Message = "导入成功";
                    }
                }
                catch (Exception ex)
                {
                    result.Successed = false;
                    result.Message = "数据存储异常";
                }

            }
            return result;
        }