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.
DS7/DSWeb/Areas/MvcShipping/DAL/MsCodeExcelImpFormat/MsCodeExcelImpFormatDAL.cs

772 lines
34 KiB
C#

3 years ago

using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsCodeExcelImpFormat;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using DSWeb.MvcShipping.Models.MsOpSeae;
using HcUtility.Core;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL;
using System.Linq;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsChFee;
using org.junit.rules;
3 years ago
namespace DSWeb.MvcShipping.DAL.MsCodeExcelImpFormatDAL
{
public class MsCodeExcelImpFormatDAL
{
#region Inquery DataList
static public List<MsCodeExcelImpFormat> GetDataList(string strCondition, string userid, string usercode, string orgcode, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("GID,FMNAME,CORPID,REMARK,BSTYPE,CREATEUSER,CREATETIME");
strSql.Append(",(select ShowName from [user] where GID=code_excel_impformat.CREATEUSER) as CREATEUSERREF");
strSql.Append(" from code_excel_impformat where CORPID='" + orgcode+"' ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by FMNAME");
}
return SetData(strSql);
}
static public MsCodeExcelImpFormat GetData(string condition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("GID,FMNAME,CORPID,BSTYPE,REMARK,CREATEUSER,CREATETIME");
strSql.Append(",(select ShowName from [user] where GID=code_excel_impformat.CREATEUSER) as CREATEUSERREF");
strSql.Append(" from code_excel_impformat ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var list = SetData(strSql);
if (list.Count > 0)
return list[0];
return new MsCodeExcelImpFormat();
}
private static List<MsCodeExcelImpFormat> SetData(StringBuilder strSql)
{
var headList = new List<MsCodeExcelImpFormat>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsCodeExcelImpFormat data = new MsCodeExcelImpFormat();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.FMNAME = Convert.ToString(reader["FMNAME"]);
data.CORPID = Convert.ToString(reader["CORPID"]);
data.BSTYPE = Convert.ToString(reader["BSTYPE"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 明细表
static public List<MsCodeExcelImpFormatDetail> GetBodyList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("*");
strSql.Append(" from code_excel_impformat_detail ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" order by SORTID ");
return SetBodyData(strSql);
}
private static List<MsCodeExcelImpFormatDetail> SetBodyData(StringBuilder strSql)
{
var bodyList = new List<MsCodeExcelImpFormatDetail>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsCodeExcelImpFormatDetail data = new MsCodeExcelImpFormatDetail();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.LINKGID = Convert.ToString(reader["LINKGID"]);
data.TABLETYPE = Convert.ToString(reader["TABLETYPE"]);
data.FIELDNAME = Convert.ToString(reader["FIELDNAME"]);
data.COLUMNNAME = Convert.ToString(reader["COLUMNNAME"]);
data.FIELDTYPE = Convert.ToString(reader["FIELDTYPE"]);
data.DEFVALUE = Convert.ToString(reader["DEFVALUE"]);
data.FEENAME = Convert.ToString(reader["FEENAME"]);
data.ISDEF = Convert.ToString(reader["ISDEF"]);
data.REMARKS = Convert.ToString(reader["REMARKS"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
static public List<MsCodeExcelImpFormatFee> GetFeeList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("*");
strSql.Append(" from code_excel_impformat_fee ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" order by SORTID ");
return SetFeeData(strSql);
}
private static List<MsCodeExcelImpFormatFee> SetFeeData(StringBuilder strSql)
{
var bodyList = new List<MsCodeExcelImpFormatFee>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsCodeExcelImpFormatFee data = new MsCodeExcelImpFormatFee();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.LINKGID = Convert.ToString(reader["LINKGID"]);
data.FEEDESCRP = Convert.ToString(reader["FEEDESCRP"]);
data.FEENAME = Convert.ToString(reader["FEENAME"]);
if (reader["FEETYPE"] != DBNull.Value)
data.FEETYPE = Convert.ToInt16(reader["FEETYPE"]);//
data.REMARKS = Convert.ToString(reader["REMARKS"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
#endregion
public static DBResult SaveDetail(string GID, List<MsCodeExcelImpFormatDetail> bodyList, List<MsCodeExcelImpFormatFee> feeList)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into code_excel_impformat_detail (GID, LINKGID,FIELDNAME,TABLETYPE,COLUMNNAME,ISDEF,FIELDTYPE,DEFVALUE,REMARKS,FEENAME)
values (@GID,@LINKGID,@FIELDNAME,@TABLETYPE,@COLUMNNAME,@ISDEF,@FIELDTYPE,@DEFVALUE,@REMARKS,@FEENAME) ");
var cmdUpdate =
db.GetSqlStringCommand(
@"update code_excel_impformat_detail set FIELDNAME=@FIELDNAME,TABLETYPE=@TABLETYPE,COLUMNNAME=@COLUMNNAME,FIELDTYPE=@FIELDTYPE
,ISDEF=@ISDEF,DEFVALUE=@DEFVALUE,REMARKS=@REMARKS,FEENAME=@FEENAME where GID=@GID ");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (enumValue.LINKGID == "" || enumValue.LINKGID == "*")
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@GID", DbType.String, enumValue.GID);
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, GID);
db.AddInParameter(cmdInsert, "@FIELDNAME", DbType.String, enumValue.FIELDNAME);
db.AddInParameter(cmdInsert, "@TABLETYPE", DbType.String, enumValue.TABLETYPE);
db.AddInParameter(cmdInsert, "@COLUMNNAME", DbType.String, enumValue.COLUMNNAME);
db.AddInParameter(cmdInsert, "@FIELDTYPE", DbType.String, enumValue.FIELDTYPE);
db.AddInParameter(cmdInsert, "@ISDEF", DbType.String, enumValue.ISDEF);
db.AddInParameter(cmdInsert, "@DEFVALUE", DbType.String, enumValue.DEFVALUE);
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FEENAME);
db.AddInParameter(cmdInsert, "@REMARKS", DbType.String, enumValue.REMARKS);
db.ExecuteNonQuery(cmdInsert, tran);
}
else {
cmdUpdate.Parameters.Clear();
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
db.AddInParameter(cmdUpdate, "@FIELDNAME", DbType.String, enumValue.FIELDNAME);
db.AddInParameter(cmdUpdate, "@TABLETYPE", DbType.String, enumValue.TABLETYPE);
db.AddInParameter(cmdUpdate, "@COLUMNNAME", DbType.String, enumValue.COLUMNNAME);
db.AddInParameter(cmdUpdate, "@FIELDTYPE", DbType.String, enumValue.FIELDTYPE);
db.AddInParameter(cmdUpdate, "@ISDEF", DbType.String, enumValue.ISDEF);
db.AddInParameter(cmdUpdate, "@DEFVALUE", DbType.String, enumValue.DEFVALUE);
db.AddInParameter(cmdUpdate, "@REMARKS", DbType.String, enumValue.REMARKS);
db.AddInParameter(cmdUpdate, "@FEENAME", DbType.String, enumValue.FEENAME);
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
var cmdInsertFee=
db.GetSqlStringCommand(
@"insert into code_excel_impformat_fee (GID, LINKGID,FEENAME,REMARKS,FEEDESCRP,FEETYPE)
values (@GID,@LINKGID,@FEENAME,@REMARKS,@FEEDESCRP,@FEETYPE) ");
var cmdUpdateFee =
db.GetSqlStringCommand(
@"update code_excel_impformat_fee set FEENAME=@FEENAME,REMARKS=@REMARKS,FEEDESCRP=@FEEDESCRP,FEETYPE=@FEETYPE where GID=@GID ");
if (feeList != null)
{
foreach (var enumValue in feeList)
{
if (enumValue.LINKGID == "" || enumValue.LINKGID == "*")
{
cmdInsertFee.Parameters.Clear();
db.AddInParameter(cmdInsertFee, "@GID", DbType.String, enumValue.GID);
db.AddInParameter(cmdInsertFee, "@LINKGID", DbType.String, GID);
db.AddInParameter(cmdInsertFee, "@FEENAME", DbType.String, enumValue.FEENAME);
db.AddInParameter(cmdInsertFee, "@REMARKS", DbType.String, enumValue.REMARKS);
db.AddInParameter(cmdInsertFee, "@FEEDESCRP", DbType.String, enumValue.FEEDESCRP);
db.AddInParameter(cmdInsertFee, "@FEETYPE", DbType.Int16, enumValue.FEETYPE);
db.ExecuteNonQuery(cmdInsertFee, tran);
}
else
{
cmdUpdateFee.Parameters.Clear();
db.AddInParameter(cmdUpdateFee, "@GID", DbType.String, enumValue.GID);
db.AddInParameter(cmdUpdateFee, "@FEENAME", DbType.String, enumValue.FEENAME);
db.AddInParameter(cmdUpdateFee, "@REMARKS", DbType.String, enumValue.REMARKS);
db.AddInParameter(cmdUpdateFee, "@FEEDESCRP", DbType.String, enumValue.FEEDESCRP);
db.AddInParameter(cmdUpdateFee, "@FEETYPE", DbType.Int16, enumValue.FEETYPE);
db.ExecuteNonQuery(cmdUpdateFee, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功";
return result;
}
public static DBResult SaveBodyDetail(string GID, List<MsCodeExcelImpFormatDetail> bodyList)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdInsert =
db.GetSqlStringCommand(
@"insert into code_excel_impformat_detail (GID, LINKGID,FIELDNAME,TABLETYPE,COLUMNNAME,ISDEF,FIELDTYPE,DEFVALUE,REMARKS,FEENAME)
values (@GID,@LINKGID,@FIELDNAME,@TABLETYPE,@COLUMNNAME,@ISDEF,@FIELDTYPE,@DEFVALUE,@REMARKS,@FEENAME) ");
var cmdUpdate =
db.GetSqlStringCommand(
@"update code_excel_impformat_detail set FIELDNAME=@FIELDNAME,TABLETYPE=@TABLETYPE,COLUMNNAME=@COLUMNNAME,FIELDTYPE=@FIELDTYPE
,ISDEF=@ISDEF,DEFVALUE=@DEFVALUE,REMARKS=@REMARKS,FEENAME=@FEENAME where GID=@GID ");
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (enumValue.LINKGID == "" || enumValue.LINKGID == "*")
{
cmdInsert.Parameters.Clear();
db.AddInParameter(cmdInsert, "@GID", DbType.String, enumValue.GID);
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, GID);
db.AddInParameter(cmdInsert, "@FIELDNAME", DbType.String, enumValue.FIELDNAME);
db.AddInParameter(cmdInsert, "@TABLETYPE", DbType.String, enumValue.TABLETYPE);
db.AddInParameter(cmdInsert, "@COLUMNNAME", DbType.String, enumValue.COLUMNNAME);
db.AddInParameter(cmdInsert, "@FIELDTYPE", DbType.String, enumValue.FIELDTYPE);
db.AddInParameter(cmdInsert, "@ISDEF", DbType.String, enumValue.ISDEF);
db.AddInParameter(cmdInsert, "@DEFVALUE", DbType.String, enumValue.DEFVALUE);
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FEENAME);
db.AddInParameter(cmdInsert, "@REMARKS", DbType.String, enumValue.REMARKS);
db.ExecuteNonQuery(cmdInsert, tran);
}
else
{
cmdUpdate.Parameters.Clear();
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
db.AddInParameter(cmdUpdate, "@FIELDNAME", DbType.String, enumValue.FIELDNAME);
db.AddInParameter(cmdUpdate, "@TABLETYPE", DbType.String, enumValue.TABLETYPE);
db.AddInParameter(cmdUpdate, "@COLUMNNAME", DbType.String, enumValue.COLUMNNAME);
db.AddInParameter(cmdUpdate, "@FIELDTYPE", DbType.String, enumValue.FIELDTYPE);
db.AddInParameter(cmdUpdate, "@ISDEF", DbType.String, enumValue.ISDEF);
db.AddInParameter(cmdUpdate, "@DEFVALUE", DbType.String, enumValue.DEFVALUE);
db.AddInParameter(cmdUpdate, "@REMARKS", DbType.String, enumValue.REMARKS);
db.AddInParameter(cmdUpdate, "@FEENAME", DbType.String, enumValue.FEENAME);
db.ExecuteNonQuery(cmdUpdate, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "保存出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功";
return result;
}
public static DBResult DeleteDetail(MsCodeExcelImpFormat headData)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("delete from code_excel_impformat_detail where LINKGID='" + headData.GID + "'");
db.ExecuteNonQuery(cmdDelete, tran);
var cmdDeletefee = db.GetSqlStringCommand("delete from code_excel_impformat_fee where LINKGID='" + headData.GID + "'");
db.ExecuteNonQuery(cmdDeletefee, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功";
return result;
}
public static DBResult DeleteDetail(string GID)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("delete from code_excel_impformat_detail where GID='" + GID + "'");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功";
return result;
}
public static DBResult DeleteFeeDetail(string GID)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var cmdDelete = db.GetSqlStringCommand("delete from code_excel_impformat_fee where GID='" + GID + "'");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "删除出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "保存成功";
return result;
}
public static DBResult ImpOpSeae(DataTable table,string fmid, string userid, string username, string companyid)
{
var bodylist = GetBodyList("LINKGID='" + fmid + "'");
var feelist = GetFeeList("LINKGID='" + fmid + "'");
var result = new DBResult();
try
{
foreach (DataRow row in table.Rows)
{
if (row[0].ToString() != "")
{
var headData = new MsOpSeae();
headData.OP = username;
headData.DOC = username;
headData.CUSTSERVICE = username;
headData.INPUTBY = username;
headData.BSDATE = DateTime.Now;
headData.BSSTATUS = false;
headData.FEESTATUS = false;
headData.DbOperationType = DbOperationType.DbotIns;
headData.BLTYPE = "整箱";
headData.FENPIAO = "0";
if (headData.CORPID == "" || headData.CORPID == null)
{
headData.CORPID = companyid;
}
if (headData.SALECORPID == "" || headData.SALECORPID == null)
{
headData.SALECORPID = companyid;
}
var propArr = headData.GetType().GetProperties();
foreach (var items in bodylist)
{
var prop = propArr.FirstOrDefault(p => p.Name.ToLower() == items.FIELDNAME.ToLower());
object strVal = null;
if (items.ISDEF == "1")
{
strVal = items.DEFVALUE;
}
else if (items.COLUMNNAME != "")
{
strVal = row[items.COLUMNNAME];
}
if (prop.PropertyType == typeof(string))
{
prop.SetValue(headData, strVal);
}
else if (prop.PropertyType == typeof(DateTime?))
{
DateTime dtTmp = DateTime.MinValue;
if (DateTime.TryParse(Convert.ToString(strVal), out dtTmp))
{
prop.SetValue(headData, dtTmp);
}
}
else if (prop.PropertyType.Name == "Decimal")
{
prop.SetValue(headData, Convert.ToDecimal(strVal));
}
else if (prop.PropertyType == typeof(int?))
{
prop.SetValue(headData, Convert.ToInt32(strVal));
}
else if (prop.PropertyType == typeof(bool?))
{
prop.SetValue(headData, Convert.ToBoolean(strVal));
}
}
if (string.IsNullOrEmpty(headData.ACCDATE))
{
var period = ChMonthCloseDAL.ChMonthCloseDAL.GetData("", companyid);
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
{
headData.ACCDATE = period.PERIOD;
}
else
{
headData.ACCDATE = DateTime.Now.ToString("yyyy-MM");
}
}
if (headData.MASTERNO == null || headData.MASTERNO == "") { headData.MASTERNO = headData.BSNO; }
if (headData.ETA == "") headData.ETA = null;
if (headData.ETD == "") headData.ETD = null;
if (headData.STLDATE == "") headData.STLDATE = null;
if (headData.ISSUEDATE == "" || (Convert.ToDateTime(headData.ISSUEDATE) < Convert.ToDateTime("2010-01-01"))) headData.ISSUEDATE = null;
if (headData.CLOSINGDATE == "") headData.CLOSINGDATE = null;
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null;
if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
if (headData.CLEARCUSTOMDATE == "") headData.CLEARCUSTOMDATE = null;
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='海运出口' AND RULEBLNO='委托编号' ", companyid);
if (billnoset.BILLTYPE != "")
headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID);
var modb = new ModelObjectDB();
result = modb.Save(headData);
if (result.Success)
{
if (feelist != null)
{
var newfeelist = new List<MsChFee>();
foreach (var feeitems in feelist)
{
var enumValueBody = new MsChFee();
enumValueBody.GId = Guid.NewGuid().ToString();
enumValueBody.BsNo = "*";
enumValueBody.FeeType = feeitems.FEETYPE;
enumValueBody.FeeStatus = 0;
enumValueBody.FeeName = feeitems.FEENAME;
var propFeeArr = enumValueBody.GetType().GetProperties();
var Feebodylist = GetBodyList("LINKGID='" + feeitems.GID + "'");
foreach (var items in Feebodylist)
{
if (!string.IsNullOrEmpty(items.FIELDNAME))
{
var prop = propFeeArr.FirstOrDefault(p => p.Name.ToLower() == items.FIELDNAME.ToLower());
object strVal = null;
if (items.ISDEF == "1")
{
strVal = items.DEFVALUE;
}
else if (items.COLUMNNAME != "")
{
strVal = row[items.COLUMNNAME];
}
if (prop.PropertyType == typeof(string))
{
prop.SetValue(enumValueBody, strVal);
}
else if (prop.PropertyType == typeof(DateTime?))
{
DateTime dtTmp = DateTime.MinValue;
if (DateTime.TryParse(Convert.ToString(strVal), out dtTmp))
{
prop.SetValue(enumValueBody, dtTmp);
}
}
else if (prop.PropertyType.Name == "Decimal")
{
prop.SetValue(enumValueBody, Convert.ToDecimal(strVal));
}
else if (prop.PropertyType == typeof(int?))
{
prop.SetValue(enumValueBody, Convert.ToInt32(strVal));
}
else if (prop.PropertyType == typeof(bool?))
{
prop.SetValue(enumValueBody, Convert.ToBoolean(strVal));
}
}
}
if (enumValueBody.Amount != 0 && enumValueBody.NoTaxAmount == 0)
{
if (enumValueBody.TaxRate == 0) enumValueBody.NoTaxAmount = enumValueBody.Amount;
}
if (enumValueBody.TaxUnitPrice != 0 && enumValueBody.UnitPrice == 0)
{
if (enumValueBody.TaxRate == 0) enumValueBody.UnitPrice = enumValueBody.TaxUnitPrice;
}
if (enumValueBody.Currency != "RMB" && (enumValueBody.ExChangerate == 1 || enumValueBody.ExChangerate == 0))
{
enumValueBody.ExChangerate = MsChFeeDAL.MsChFeeDAL.GetExrate(DateTime.Now.ToString(), companyid, enumValueBody.Currency);
}
enumValueBody.EnteroPerator = userid;
if (enumValueBody.Amount!=0)
newfeelist.Add(enumValueBody);
}
if (newfeelist.Count!=0)
MsChFeeDAL.MsChFeeDAL.SaveUpdateFee(newfeelist, headData.BSNO, userid);
}
}
}
}
result.Success = true;
result.Message = "导入成功";
}
catch (Exception ex)
{
result.Success = false;
result.Message = "导入中出错:"+ex.Message;
}
return result;
}
#region 参照部分
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 ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modOpApplyService' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
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"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "S.OP='" + username + "'";
}
else if (visiblerange == "3")
{
str = "S.OP='" + username + "'";
}
else if (visiblerange == "2")
{
var rangeDa = new RangeDA();
var deptname = rangeDa.GetDEPTNAME(userid);
//str = " S.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 + "'))";
str = $" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' and DEPTNAME='{deptname}')";
3 years ago
}
else if (visiblerange == "1")
{
//str = " S.OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')) ";
str = $" exists(select 1 from vw_user where SHOWNAME =S.OP and COMPANYID='{companyid}' )";
3 years ago
}
else if (visiblerange == "0")
{
str = " 1=1 ";
}
return str;
}
#endregion
}
}