using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CoreFS.CA06;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Infragistics.Win.UltraWinGrid;
using System.Collections;
using ColumnDefine = Core.StlMes.Client.Sale.Common.TbColumnDefine.TbColumnDefine;
namespace Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.BaseData
{
public class SlmBaseForecorpInfoBll : SaleBusinessMgt.BllBase.BaseBll
{
public SlmBaseForecorpInfoBll(OpeBase ob)
: base(ob)
{
}
///
/// 查询入口
///
///
///
private DataSet GetSlmBaseForeorp(string sqlCondition)
{
string sqlStr = string.Format(SqlCollection.BaseData._QUERYSLMFORECORPINFO, sqlCondition, base.DateTimeTocharFormat);
return base.ExecuteQuery(sqlStr);
}
///
/// 根据validflag查询数据
///
///
///
public DataSet GetValidSlmBaseForecorpInfo()
{
string sqlCondition = string.Format(" and validflag = '{0}' ", "1");
return GetSlmBaseForeorp(sqlCondition);
}
///
/// 通过子公司名称查询数据
///
///
///
public DataSet GetSlmBaseForecorpInfoByForeCorpName(string foreCorpName)
{
string sqlCondition = string.Format(" and forecorpname = '{0}'", foreCorpName);
return GetSlmBaseForeorp(sqlCondition);
}
///
/// 新增子公司信息
///
///
///
public void Insert(Hashtable hs, out string errMsg)
{
errMsg = "";
hs.Add(ColumnDefine.SLM_BASE_FORECORPINFO.FORECORPCODE, GetSlmBaseForecorpInfoCode());
CoreClientParam param = base.GetCoreClientParam(_ServerName, "insert", new object[] { hs });
CoreClientParam result = base.fr.ExecuteNonQuery(param, CoreInvokeType.Internal);
errMsg = base.GetReturnErrorInfo(result);
}
///
/// 修改子公司信息
///
///
///
public void Update(Hashtable hs, out string errMsg)
{
errMsg = "";
CoreClientParam param = base.GetCoreClientParam(_ServerName, "update", new object[] { hs });
CoreClientParam result = base.fr.ExecuteNonQuery(param, CoreInvokeType.Internal);
errMsg = base.GetReturnErrorInfo(result);
}
///
/// 删除
///
///
public void Delete(string forecorpCode,string deleteName,out string errMsg)
{
errMsg = "";
CoreClientParam param = base.GetCoreClientParam(_ServerName, "delete", new object[] { forecorpCode,deleteName });
CoreClientParam result = base.fr.ExecuteNonQuery(param, CoreInvokeType.Internal);
errMsg = base.GetReturnErrorInfo(result);
}
///
/// 获取数据行数
///
///
private double GetCoutOfSlmBaseForecorpInfo()
{
string sqlStr = "select count(1) from slm_base_forecorpinfo ";
DataSet ds = base.ExecuteQuery(sqlStr);
if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
return 0;
return Util.ConverObject.ConvertToDouble(ds.Tables[0].Rows[0][0]);
}
///
/// 自动生成客户编码
///
///
private string GetSlmBaseForecorpInfoCode()
{
string customberno = "";
string sqlStr = @"select *
from (select lpad(l || '', 6, 0) customberno, a.forecorpcode, rownum rn
from (select level - 1 l from dual connect by level < {0}) b
left join slm_base_forecorpinfo a on a.forecorpcode =
lpad(b.l || '', 6, 0)
where a.forecorpcode is null
order by b.l)
where rn = 1";
sqlStr = string.Format(sqlStr, GetCoutOfSlmBaseForecorpInfo() + 100);
DataSet ds = base.ExecuteQuery(sqlStr);
try
{
if (ds.Tables[0].Rows.Count == 0)
customberno = "000001";
else
customberno = ds.Tables[0].Rows[0]["CUSTOMBERNO"].ToString();
}
catch
{
}
return customberno;
}
///
/// 服务器方法名路径
///
private string _ServerName = "core.stlmes.server.sale.service.basedata.SlmBaseForecorpInfo";
}
}