using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DBUtility
|
{
|
public class ClsGy_Base_View:IDisposable
|
{
|
public string MvarReportTitle; //标题
|
public string MvarItemKey; //key 表名 视图名
|
public string WherePart; //查找
|
public string SQLName; //选择SQL
|
public string SQLOrder; //选择SQL
|
public string SQLWhere; //选择SQL
|
public string SQLNameForNew; //选择SQL
|
public string SQLOrderForNew; //选择SQL
|
public string SQLWhereForNew; //选择SQL
|
public string SQLNameByRelation; //选择SQL根据关联
|
public string ViewNameForWeb; //根据内码返回视图
|
public string SQLNameForDown; //选择SQL
|
public string SQLOrderForDown; //选择SQL
|
public string SQLWhereForDown; //选择SQL
|
//big
|
public string sBillView;
|
public string sBillShowItem;
|
public string sBillColName;
|
public string sBillColNumber;
|
public string sBillOrder;
|
//
|
public string SQLList;
|
//
|
Pub_Class.ClsSqlHelper oCN = new Pub_Class.ClsSqlHelper();
|
public ClsGy_Base_Model oModel = new ClsGy_Base_Model();
|
public List<ClsGy_Base_Model> oModelList = new List<ClsGy_Base_Model>();
|
|
public ClsGy_Base_View()
|
{
|
|
}
|
//
|
public void Dispose()
|
{
|
GC.SuppressFinalize(this);
|
}
|
//
|
|
|
|
//帮助
|
public virtual bool RefreshView(string sLike)
|
{
|
try
|
{//
|
Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
|
//
|
string sSQL = SQLName + SQLWhere + sLike + SQLOrder;
|
//编辑ofrm
|
ofrm.sTitle = MvarReportTitle;
|
ofrm.sBill = MvarItemKey;
|
ofrm.txtFindInfo.Text = WherePart;
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
//绑定
|
ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
|
Ds.Dispose();
|
Ds = null;
|
ofrm.grdShow.SuspendLayout();
|
ofrm.grdShow.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdShow.CurrentRow == null)
|
{
|
return false;
|
}
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
|
oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
|
oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
/// <summary>
|
/// 基础资料帮助-关联物料型
|
/// </summary>
|
/// <param name="HMaterID"></param>
|
/// <returns></returns>
|
public virtual bool RefreshViewByRelation(long HMaterID)
|
{
|
try
|
{//
|
Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
|
//
|
string sSQL = SQLNameByRelation + " where HMaterID=" + HMaterID.ToString() + " order by HItemID";
|
//编辑ofrm
|
ofrm.sTitle = MvarReportTitle;
|
ofrm.sBill = MvarItemKey;
|
ofrm.txtFindInfo.Text = WherePart;
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
//绑定
|
ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
|
Ds.Dispose();
|
Ds = null;
|
ofrm.grdShow.SuspendLayout();
|
ofrm.grdShow.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
if (ofrm.grdShow.CurrentRow == null)
|
{
|
return false;
|
}
|
//
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdShow.CurrentRow == null)
|
{
|
return false;
|
}
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
|
oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
|
oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
/// <summary>
|
/// 基础资料帮助-全部型
|
/// </summary>
|
/// <returns></returns>
|
public virtual bool RefreshView()
|
{
|
try
|
{//
|
Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
|
//
|
string sSQL = SQLName + SQLWhere + SQLOrder;
|
//编辑ofrm
|
ofrm.sTitle = MvarReportTitle;
|
ofrm.sBill = MvarItemKey;
|
ofrm.txtFindInfo.Text = WherePart;
|
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
|
//绑定
|
ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
|
Ds.Dispose();
|
Ds = null;
|
ofrm.grdShow.SuspendLayout();
|
ofrm.grdShow.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdShow.CurrentRow == null)
|
{
|
return false;
|
}
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
|
oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
|
oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
/// <summary>
|
/// 基础资料帮助-过滤条件型
|
/// </summary>
|
/// <param name="sWhere"></param>
|
/// <returns></returns>
|
public virtual bool RefreshViewForNew(string sWhere )
|
{
|
try
|
{//
|
Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
|
//
|
string sSQL = SQLNameForNew + SQLWhereForNew + sWhere + SQLOrderForNew;
|
//编辑ofrm
|
ofrm.sTitle = MvarReportTitle;
|
ofrm.sBill = MvarItemKey;
|
ofrm.txtFindInfo.Text = WherePart;
|
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
|
//绑定
|
ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
|
Ds.Dispose();
|
Ds = null;
|
ofrm.grdShow.SuspendLayout();
|
ofrm.grdShow.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdShow.CurrentRow == null)
|
{
|
return false;
|
}
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
|
oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
|
oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
/// <summary>
|
/// 基础资料帮助-返回多个项目型
|
/// </summary>
|
/// <returns></returns>
|
public virtual bool RefreshViewMul()
|
{
|
try
|
{//
|
Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
|
//
|
string sSQL = SQLName + SQLWhere + SQLOrder;
|
//编辑ofrm
|
ofrm.sTitle = MvarReportTitle;
|
ofrm.sBill = MvarItemKey;
|
ofrm.txtFindInfo.Text = WherePart;
|
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
|
//绑定
|
ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
|
Ds.Dispose();
|
Ds = null;
|
ofrm.grdShow.SuspendLayout();
|
ofrm.grdShow.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
oModelList.Clear();
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdShow.SelectedRows == null)
|
{
|
return false;
|
}
|
for (int i = 0; i < ofrm.grdShow.SelectedRows.Count; i++)
|
{
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[i].Index].Cells[0].Value);
|
oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[i].Index].Cells[1].Value);
|
oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[i].Index].Cells[2].Value);
|
oModelList.Add(oModel);
|
}
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
/// <summary>
|
/// 基础资料帮助-大数据型
|
/// </summary>
|
/// <returns></returns>
|
public virtual bool RefreshViewForBig(string sLike)
|
{
|
try
|
{//
|
Pub_Control.frmHlpInfoForBig ofrm = new Pub_Control.frmHlpInfoForBig();
|
//
|
//string sSQL = SQLName + SQLWhere + SQLOrder;
|
//编辑ofrm
|
ofrm.sTitle = MvarReportTitle;
|
ofrm.sBill = sBillView;
|
ofrm.txtFindInfo.Text = "";
|
ofrm.sOtherItem = sBillShowItem;
|
ofrm.sNameColName =sBillColName;
|
ofrm.sNumberColName = sBillColNumber;
|
ofrm.sOrderItem = sBillOrder;
|
ofrm.sLike = sLike;
|
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
//Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
//if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
//{
|
// return false;
|
//}
|
|
//绑定
|
//ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
|
//Ds.Dispose();
|
//Ds = null;
|
ofrm.grdShow.SuspendLayout();
|
//ofrm.grdShow.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdShow.CurrentRow == null)
|
{
|
return false;
|
}
|
//for (int i = 0; i < ofrm.grdShow.SelectedRows.Count; i++)
|
//{
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[0].Index].Cells[0].Value);
|
oModelList.Add(oModel);
|
//}
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
/// <summary>
|
/// 基础资料帮助-下拉框型
|
/// </summary>
|
/// <param name="s"></param>
|
/// <param name="x"></param>
|
/// <param name="y"></param>
|
/// <returns></returns>
|
public virtual bool RefreshViewDownMenu(string s,int x,int y)
|
{
|
try
|
{//
|
Pub_Control.frmDownMenu ofrm = new Pub_Control.frmDownMenu();
|
//
|
string sSQL = SQLNameForDown + SQLWhereForDown + s + SQLOrderForDown;
|
//编辑ofrm
|
ofrm.x = x;
|
ofrm.y = y;
|
ofrm.sWhere = s;
|
ofrm.sTitle = this.MvarReportTitle;
|
|
//
|
DataSet Ds;
|
Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
|
Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
//绑定
|
ofrm.grdMain.DataSource = Ds.Tables[0].DefaultView;
|
Ds.Dispose();
|
Ds = null;
|
ofrm.grdMain.SuspendLayout();
|
ofrm.grdMain.Columns[0].Visible = false;
|
ofrm.ShowDialog();
|
//得到对应列
|
int HItemIDCol = 0;
|
int HNumberCol = 1;
|
int HNameCol = 2;
|
//
|
if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
|
{
|
if (ofrm.grdMain.CurrentRow == null)
|
{
|
return false;
|
}
|
oModel = new ClsGy_Base_Model();
|
oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdMain.Rows[ofrm.grdMain.CurrentRow.Index].Cells[HItemIDCol].Value);
|
oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdMain.Rows[ofrm.grdMain.CurrentRow.Index].Cells[HNumberCol].Value);
|
oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdMain.Rows[ofrm.grdMain.CurrentRow.Index].Cells[HNameCol].Value);
|
}
|
else
|
{
|
return false;
|
}
|
//
|
ofrm.Dispose();
|
ofrm = null;
|
//
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
/// <summary>
|
/// 根据内码返回Dataset
|
/// </summary>
|
/// <param name="sItemID"></param>
|
/// <returns></returns>
|
public virtual DataSet GetDSByID(Int64 sItemID)
|
{
|
DataSet DS;
|
try
|
{
|
DS = oCN.RunProcReturn("Select * from " + ViewNameForWeb + " Where HItemID='" + sItemID + "'", ViewNameForWeb, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
{
|
return DS;
|
}
|
else
|
{
|
return DS;
|
}
|
}
|
catch (Exception e)
|
{
|
return null;
|
}
|
}
|
|
|
//返回项目信息
|
public virtual bool GetInfoByID(Int64 sItemID)
|
{
|
return true;
|
}
|
//根据代码返回项目信息
|
public virtual bool GetInfoByNumber(string sNumber)
|
{
|
return true;
|
}
|
//根据名称返回项目信息
|
public virtual bool GetInfoByName(string sName)
|
{
|
DataSet DS;
|
try
|
{
|
DS = oCN.RunProcReturn("Select * from " + MvarItemKey + " Where HName='" + sName + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
return false;
|
else
|
{
|
return GetInfo(DS);
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
//返回项目信息
|
public virtual bool GetInfo(DataSet DS)
|
{
|
return true;
|
}
|
|
/// <summary>
|
/// 根据sWhere 返回项目集合Dataset
|
/// </summary>
|
/// <param name="sWhere"></param>
|
/// <returns></returns>
|
public virtual DataSet GetList(string sWhere)
|
{
|
try
|
{
|
return oCN.RunProcReturn(SQLList + " " + sWhere + " Order by HNumber ", this.MvarItemKey, ref ClsPub.sExeReturnInfo);
|
}
|
catch (Exception e)
|
{
|
ClsPub.sExeReturnInfo += "返回列表失败!" + e.Message;
|
return null;
|
}
|
}
|
}
|
}
|