You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
6.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Services;
using HcUtility.Comm;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.CommMng.DAL;
using System.Data;
namespace DSWebMobileService
{
/// <summary>
/// ChfeePayApplication 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class ChfeePayApplication : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public static DBResult AuditList(string BILLNO, int BILLSTATUS, String USERID)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var errmsg = "";
var cmdupdate = db.GetSqlStringCommand("update ch_fee_payapplication set BILLSTATUS=0,AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BILLNO=@BILLNO");
var cmdupdate2 = db.GetSqlStringCommand("update ch_fee_payapplication set AUDITUSER='" + USERID + "',AUDITTIME='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where BILLNO=@BILLNO");
var feecount = GetRdCount(" FEESTATUS NOT IN (0,8,9) AND GID IN (SELECT FEEID FROM CH_FEE_DO WHERE BILLNO='" + BILLNO + "')");
if (feecount == 0)
{
if (BILLSTATUS == 2 || BILLSTATUS == 6)
{
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo("FeeSettleAudit", BILLNO, USERID);
if (WorkResult.Success == true)
{
if (WorkResult.islast == true)
{
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, BILLNO);
db.ExecuteNonQuery(cmdupdate, tran);
}
else
{
cmdupdate2.Parameters.Clear();
db.AddInParameter(cmdupdate2, "@BILLNO", DbType.String, BILLNO);
db.ExecuteNonQuery(cmdupdate2, tran);
}
}
}
}
else
{
errmsg = errmsg + "单号:" + BILLNO + ",";
}
if (errmsg != "") errmsg = ",但其中(" + errmsg + ")存在未审核费用明细,未审核通过,请先审核费用!";
result = new DBResult();
result.Success = true;
result.Message = "审核通过" + errmsg;
tran.Commit();
}
catch (Exception e)
{
tran.Rollback();
result.Success = false;
result.Message = "审核出现错误,请重试或联系系统管理员";
return result;
}
}
return result;
}
[WebMethod]
public static DBResult AuditBackList(string BILLNO, int BILLSTATUS, String USERID)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdupdate = db.GetSqlStringCommand("update ch_fee_payapplication set BILLSTATUS=6,AUDITUSER='',AUDITTIME=null where BILLNO=@BILLNO");
if (BILLSTATUS == 2 || BILLSTATUS == 0)
{
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo("FeeSettleAudit", BILLNO, USERID, "");
if (WorkResult.Success == true)
{
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, BILLNO);
db.ExecuteNonQuery(cmdupdate, tran);
}
}
result = new DBResult();
result.Success = true;
result.Message = "完成驳回";
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "驳回出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "完成驳回";
return result;
}
static public int GetRdCount(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT Count(GID) AS CT from ch_fee (NOLOCK) ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
var ct = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
ct = Convert.ToInt16(reader["CT"]);
}
reader.Close();
}
return ct;
}
}
}