|
|
|
@ -0,0 +1,559 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.Models.MsOpSaleRpt;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
using HcUtility.Comm;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
using DSWeb.MvcShipping.Models.CodeCtnEdi;
|
|
|
|
|
using com.sun.tools.@internal.xjc.reader.gbind;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsOpSaleRptDAL
|
|
|
|
|
{
|
|
|
|
|
public class MsOpSaleRptDAL
|
|
|
|
|
{
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
static public List<MsOpSaleRpt> GetDataList(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = "";
|
|
|
|
|
// GetRangDAStr("index", userid, usercode, companyid);
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT [GID],[BSNO],[MBLNO],[CUSTOMERNAME],[ACCDATE],[OP],[SALE],[ETD],[REMARK],[RMBDR],[USDDR],[STLRMBDR],[STLUSDDR],[BALRMBDR],[BALUSDDR],[TTLBALDR],[CREATETIME],[MODIFIEDTIME]"
|
|
|
|
|
+ ",PLANDATE,RPTSTATUS,(select top 1 showname from [user] where GID=op_sale_rpt.CREATEUSER) as CREATEUSER,(select top 1 showname from [user] where GID=op_sale_rpt.MODIFIEDUSER) as MODIFIEDUSER"
|
|
|
|
|
+ " FROM op_sale_rpt ";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string userid, string usercode, string companyid, string sort = null)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = "";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strCondition = rangstr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
String strSql = "SELECT [GID],[BSNO],[MBLNO],[CUSTOMERNAME],[ACCDATE],[OP],[SALE],[ETD],[REMARK],[RMBDR],[USDDR],[STLRMBDR],[STLUSDDR],[BALRMBDR],[BALUSDDR],[TTLBALDR],[CREATETIME],[MODIFIEDTIME]"
|
|
|
|
|
+ ",PLANDATE,RPTSTATUS,(select top 1 showname from [user] where GID=op_sale_rpt.CREATEUSER) as CREATEUSER,(select top 1 showname from [user] where GID=op_sale_rpt.MODIFIEDUSER) as MODIFIEDUSER"
|
|
|
|
|
+ " FROM op_sale_rpt ";
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + strCondition;
|
|
|
|
|
}
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by " + sortstring;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql += " order by ETD desc";
|
|
|
|
|
}
|
|
|
|
|
return strSql.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public MsOpSaleRpt GetData(string condition)
|
|
|
|
|
{
|
|
|
|
|
String strSql = "SELECT [GID],[BSNO],[MBLNO],[CUSTOMERNAME],[ACCDATE],[OP],[SALE],[ETD],[REMARK],[RMBDR],[USDDR],[STLRMBDR],[STLUSDDR],[BALRMBDR],[BALUSDDR],[TTLBALDR],[CREATETIME],[MODIFIEDTIME]"
|
|
|
|
|
+ ",PLANDATE,RPTSTATUS,(select top 1 showname from [user] where GID=op_sale_rpt.CREATEUSER) as CREATEUSER,(select top 1 showname from [user] where GID=op_sale_rpt.MODIFIEDUSER) as MODIFIEDUSER"
|
|
|
|
|
+ " FROM op_sale_rpt ";
|
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
|
|
{
|
|
|
|
|
strSql += " where " + condition;
|
|
|
|
|
}
|
|
|
|
|
var list=SetData(strSql);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return list[0];
|
|
|
|
|
}
|
|
|
|
|
return new MsOpSaleRpt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<MsOpSaleRpt> SetData(String strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsOpSaleRpt>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsOpSaleRpt data = new MsOpSaleRpt();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");
|
|
|
|
|
if (reader["PLANDATE"] != DBNull.Value)
|
|
|
|
|
data.PLANDATE = Convert.ToDateTime(reader["PLANDATE"]).ToString("yyyy-MM-dd");
|
|
|
|
|
data.RPTSTATUS = Convert.ToString(reader["RPTSTATUS"]);
|
|
|
|
|
|
|
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
|
if (reader["RMBDR"] != DBNull.Value)
|
|
|
|
|
data.RMBDR = Convert.ToDecimal(reader["RMBDR"]);
|
|
|
|
|
if (reader["USDDR"] != DBNull.Value)
|
|
|
|
|
data.USDDR = Convert.ToDecimal(reader["USDDR"]);
|
|
|
|
|
if (reader["STLRMBDR"] != DBNull.Value)
|
|
|
|
|
data.STLRMBDR = Convert.ToDecimal(reader["STLRMBDR"]);
|
|
|
|
|
if (reader["STLUSDDR"] != DBNull.Value)
|
|
|
|
|
data.STLUSDDR = Convert.ToDecimal(reader["STLUSDDR"]);
|
|
|
|
|
if (reader["BALRMBDR"] != DBNull.Value)
|
|
|
|
|
data.BALRMBDR = Convert.ToDecimal(reader["BALRMBDR"]);
|
|
|
|
|
if (reader["BALUSDDR"] != DBNull.Value)
|
|
|
|
|
data.BALUSDDR = Convert.ToDecimal(reader["BALUSDDR"]);
|
|
|
|
|
if (reader["TTLBALDR"] != DBNull.Value)
|
|
|
|
|
data.TTLBALDR = Convert.ToDecimal(reader["TTLBALDR"]);
|
|
|
|
|
|
|
|
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
|
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
|
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);
|
|
|
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
|
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
static public List<MsOpSaleRpt> GetNewDataList()
|
|
|
|
|
{
|
|
|
|
|
String strSql = "SELECT *,(select top 1 PLANDATE from op_sale_rpt where BSNO=v_noday_fee.BSNO ORDER BY CREATETIME DESC) PLANDATE FROM v_noday_fee WHERE DATEDIFF([day],STLDATE,GETDATE())>0 ";
|
|
|
|
|
|
|
|
|
|
return SetNewData(strSql);
|
|
|
|
|
}
|
|
|
|
|
private static List<MsOpSaleRpt> SetNewData(String strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<MsOpSaleRpt>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
MsOpSaleRpt data = new MsOpSaleRpt();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
if (reader["ETD"] != DBNull.Value)
|
|
|
|
|
data.ETD = Convert.ToDateTime(reader["ETD"]).ToString("yyyy-MM-dd");
|
|
|
|
|
if (reader["PLANDATE"] != DBNull.Value)
|
|
|
|
|
data.PLANDATE = Convert.ToDateTime(reader["PLANDATE"]).ToString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
|
|
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);
|
|
|
|
|
if (reader["RMBDR"] != DBNull.Value)
|
|
|
|
|
data.RMBDR = Convert.ToDecimal(reader["RMBDR"]);
|
|
|
|
|
if (reader["USDDR"] != DBNull.Value)
|
|
|
|
|
data.USDDR = Convert.ToDecimal(reader["USDDR"]);
|
|
|
|
|
if (reader["STLRMBDR"] != DBNull.Value)
|
|
|
|
|
data.STLRMBDR = Convert.ToDecimal(reader["STLRMBDR"]);
|
|
|
|
|
if (reader["STLUSDDR"] != DBNull.Value)
|
|
|
|
|
data.STLUSDDR = Convert.ToDecimal(reader["STLUSDDR"]);
|
|
|
|
|
if (reader["BALRMBDR"] != DBNull.Value)
|
|
|
|
|
data.BALRMBDR = Convert.ToDecimal(reader["BALRMBDR"]);
|
|
|
|
|
if (reader["BALUSDDR"] != DBNull.Value)
|
|
|
|
|
data.BALUSDDR = Convert.ToDecimal(reader["BALUSDDR"]);
|
|
|
|
|
if (reader["TTLBALDR"] != DBNull.Value)
|
|
|
|
|
data.TTLBALDR = Convert.ToDecimal(reader["TTLBALDR"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
public static DBResult NewData(string userid)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var headList = GetNewDataList();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var cmdInsert =
|
|
|
|
|
db.GetSqlStringCommand(
|
|
|
|
|
@"insert into op_sale_rpt ([GID],[BSNO],[MBLNO],[CUSTOMERNAME],[ACCDATE],[OP],[SALE],[ETD],[RMBDR],[USDDR],[STLRMBDR],[STLUSDDR]
|
|
|
|
|
,[BALRMBDR],[BALUSDDR],[TTLBALDR],[CREATEUSER],[CREATETIME],[PLANDATE],[RPTSTATUS])
|
|
|
|
|
values (NEWID(),@BSNO,@MBLNO,@CUSTOMERNAME,@ACCDATE,@OP,@SALE,@ETD,@RMBDR,@USDDR,@STLRMBDR,@STLUSDDR
|
|
|
|
|
,@BALRMBDR,@BALUSDDR,@TTLBALDR,@CREATEUSER,GETDATE(),@PLANDATE,'未发布') ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (headList!=null&& headList.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in headList) {
|
|
|
|
|
|
|
|
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BSNO", DbType.String, enumValue.BSNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@MBLNO", DbType.String, enumValue.MBLNO);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CUSTOMERNAME", DbType.String, enumValue.CUSTOMERNAME);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ACCDATE", DbType.String, enumValue.ACCDATE);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@OP", DbType.String, enumValue.OP);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@SALE", DbType.String, enumValue.SALE);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@ETD", DbType.String, enumValue.ETD);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@RMBDR", DbType.Decimal, enumValue.RMBDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@USDDR", DbType.Decimal, enumValue.USDDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@STLRMBDR", DbType.Decimal, enumValue.STLRMBDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@STLUSDDR", DbType.Decimal, enumValue.STLUSDDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BALRMBDR", DbType.Decimal, enumValue.BALRMBDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@BALUSDDR", DbType.Decimal, enumValue.BALUSDDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@TTLBALDR", DbType.Decimal, enumValue.TTLBALDR);
|
|
|
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
|
|
|
if (enumValue.PLANDATE != null&& enumValue.PLANDATE!="")
|
|
|
|
|
db.AddInParameter(cmdInsert, "@PLANDATE", DbType.String, enumValue.PLANDATE);
|
|
|
|
|
else
|
|
|
|
|
db.AddInParameter(cmdInsert, "@PLANDATE", DbType.String, null);
|
|
|
|
|
|
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "保存成功";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DBResult SubmitAudit(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 op_sale_rpt set RPTSTATUS='发布',MODIFIEDTIME=GETDATE(),MODIFIEDUSER='" + userid + "' where RPTSTATUS='未发布' ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
public static DBResult SaveDetail(List<MsOpSaleRpt> bodyList,string userid, string companyid)
|
|
|
|
|
{
|
|
|
|
|
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 op_sale_rpt set PLANDATE=@PLANDATE,REMARK=@REMARK,MODIFIEDTIME=GETDATE(),MODIFIEDUSER='"+ userid + "' where GID=@GID ");
|
|
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var enumValue in bodyList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
|
|
|
if (enumValue.PLANDATE=="")
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@PLANDATE", DbType.String,null);
|
|
|
|
|
else
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@PLANDATE", DbType.String, enumValue.PLANDATE);
|
|
|
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
|
|
|
|
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
tran.Rollback();
|
|
|
|
|
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
|
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断编码是否有重复
|
|
|
|
|
static public int GetRdCount(string strCondition)
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" Count(BSNO) AS CT ");
|
|
|
|
|
strSql.Append(" from op_seae_pre ");
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Rang权限范围
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT");
|
|
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID");
|
|
|
|
|
strSql.Append(" from VW_User_Authority");
|
|
|
|
|
strSql.Append(" where [NAME]='modOpOtherList' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
|
|
string operaterange = "4";
|
|
|
|
|
string AUTHORITYID = "";
|
|
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (visiblerange == "4")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP='" + username + "' OR CREATEUSER='" + userid + "' OR SALE='" + username + "' OR CUSTSERVICE='" + username + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "3")
|
|
|
|
|
{
|
|
|
|
|
str = " (OP='" + username + "' OR CREATEUSER='" + userid + "' OR SALE='" + username + "' OR CUSTSERVICE='" + username + "')";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "2")
|
|
|
|
|
{
|
|
|
|
|
var rangeDa = new RangeDA();
|
|
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
|
|
str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))"
|
|
|
|
|
+ " OR CREATEUSER in (select GID from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "1")
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "' or op_other.SALECORPID='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "5")
|
|
|
|
|
{
|
|
|
|
|
if (tb == "index")
|
|
|
|
|
{
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
|
|
{
|
|
|
|
|
str = "";
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
if (str == "")
|
|
|
|
|
{
|
|
|
|
|
str = " (op_other.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or op_other.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "' ";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = str + " or op_other.Corpid='" + Convert.ToString(reader["COMPANYID"]) + "' or op_other.SALECORPID='" + Convert.ToString(reader["COMPANYID"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
str = str + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (visiblerange == "6")
|
|
|
|
|
{
|
|
|
|
|
if (tb == "index")
|
|
|
|
|
{
|
|
|
|
|
var opstr = "";
|
|
|
|
|
var userstr = new StringBuilder();
|
|
|
|
|
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opstr == "")
|
|
|
|
|
{
|
|
|
|
|
opstr = " ('" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
opstr = opstr + ",'" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opstr != "") opstr = opstr + ")";
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (opstr == "") opstr = "('" + username + "')";
|
|
|
|
|
str = " (OP in " + opstr + " or CREATEUSER in " + opstr + " or CUSTSERVICE IN " + opstr + " or SALE IN " + opstr + " )";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
str = " (UPPER(op_other.Corpid)='" + companyid + "') ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (visiblerange == "0")
|
|
|
|
|
{
|
|
|
|
|
str = " 1=1 ";
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|