using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using SQLHelper;
|
|
namespace DAL
|
{
|
public partial class frmHlpBillList : Form
|
{
|
public frmHlpBillList()
|
{
|
InitializeComponent();
|
}
|
public string ViewName;
|
public string tSQL;
|
public frmBillQueryCondition_New frmCondition;
|
/// <summary>
|
/// ±ÜÃâÖØ¸´ÁÐ
|
/// </summary>
|
public string sPrimaryCol;
|
public Pub_Class.ClsPub.Enum_OKTag OKTag;
|
public string sBillName="";
|
Pub_Class.ClsGridListSum oSumGrid = new Pub_Class.ClsGridListSum();
|
|
//³õʼ»¯GRID
|
private void initGrid()
|
{
|
DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name);
|
}
|
|
|
//
|
public Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
//ÏÔʾÄÚÈÝ
|
private void Display()
|
{
|
ClsCN SubCn = new ClsCN();
|
DataSet DSet;
|
string sSql = "";
|
string sWhere = tSQL; //ÌØÊâÌõ¼þ(ÈÕÆÚÏÞÖÆ£¬²¿ÃÅÏÞÖÆ)
|
DBUtility.Xt_BaseBillFun.Sub_SQLWhere(ref sWhere);
|
|
//¹ýÂËÌõ¼þ
|
if (frmCondition.SqlStr.Trim().Length == 0)
|
return;
|
sSql = frmCondition.SqlStr + sWhere ;
|
|
|
//
|
DSet = SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
|
//Éú³ÉÊ×ÐбêÌâ
|
if (DSet == null)
|
{
|
MessageBox.Show("ûÓзµ»ØÈκνá¹û,ÇëÔÚ¹ýÂË¿òÖеã»÷¡¾»Ö¸´¡¿°´Å¥,³¢ÊÔÔٴβéѯ£¡" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//ÊͷŶ³½á
|
DBUtility.Xt_BaseBillFun.CancelFrozenCol(grdMain);
|
//°ó¶¨
|
grdMain.DataSource = DSet.Tables[0].DefaultView;
|
//ÉèÖúϼÆÁÐ
|
string sTotalCol = "";
|
sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
|
//ÉèÖÃ¶ÔÆëÁÐ
|
DBUtility.Xt_BaseBillFun.DisplayGridDuiQi(grdMain, ViewName);
|
string[] sT;
|
sT = sTotalCol.Split(Convert.ToChar(","));
|
oSumGrid.BuildTotalCols(sT);
|
//
|
//¶³½á
|
int FrCol = 0;
|
string s = "ÊÇ";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
|
//»Ïß
|
GraphLine();
|
//
|
Total();
|
|
//
|
}
|
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
initGrid();
|
Display();
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_Cancel;
|
this.Visible = false;
|
}
|
|
private void sx_Click(object sender, EventArgs e)
|
{
|
timer1.Enabled = true;
|
}
|
|
|
|
private void frmHlpBillList_Load(object sender, EventArgs e)
|
{
|
frmCondition = new frmBillQueryCondition_New();
|
//this.Text = ModCaption;
|
//lblCaption.Text = ModCaption;
|
oSumGrid.ogrdMain = grdMain; //³õʼ»¯ new
|
oSumGrid.oGridsum = grdSum;
|
initGrid();
|
}
|
|
private void cx_Click(object sender, EventArgs e)
|
{
|
frmCondition = new frmBillQueryCondition_New();
|
frmCondition.Tag = "";
|
frmCondition.ViewName = ViewName;
|
frmCondition.ModName = ViewName;
|
frmCondition.ShowDialog();
|
if (frmCondition.Tag.ToString() == "OK")
|
{
|
Display();
|
}
|
}
|
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
//±£´æÁпí
|
DBUtility.ClsPub.SaveGridView(grdMain, this.Name,DBUtility.ClsPub.AppPath);
|
}
|
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
|
}
|
|
private void GraphicsGrid()
|
{
|
DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
|
}
|
|
//
|
private void GraphLine()
|
{
|
int MainIDCol = Fun_GetCol("hmainid");
|
int SubIDCol = Fun_GetCol("hsubid");
|
string s ="ÊÇ";
|
long n = 0;
|
DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
|
//ÏÔʾ
|
lbldj.Text = "²éѯ³ö " + n.ToString() + " Õŵ¥¾Ý";
|
lbljl.Text = "¹²ÓÐ " + grdMain.RowCount.ToString() + " Ìõ¼Ç¼";
|
|
}
|
//ÊÇ·ñÔÊÐí·µ»Ø
|
private bool AllowBack() //Lock
|
{
|
string stmp="";
|
int PrimaryCol;
|
if (sPrimaryCol.Trim() != "")
|
{
|
//¸ù¾ÝÃû³Æ µÃµ½ÁкÅ
|
PrimaryCol = Fun_GetCol(sPrimaryCol);
|
if (PrimaryCol == 0)
|
{
|
return true; //ûÓÐÕÒµ½
|
}
|
else
|
{
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
if (stmp == "")
|
{
|
stmp = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[PrimaryCol].Value);
|
}
|
if (stmp != DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[PrimaryCol].Value))
|
return false;
|
}
|
}
|
}
|
else
|
{
|
return true;
|
}
|
return true;
|
}
|
|
//ºÏ¼Æ new
|
private void Total()
|
{
|
if (grdMain.Rows.Count > 0 && grdMain.ColumnCount > 0)
|
{
|
oSumGrid.SetGridsum();
|
oSumGrid.Total();
|
}
|
}
|
//ºÏ¼Æ new
|
private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
|
{
|
Total();
|
}
|
//ºÏ¼Æ new
|
private void grdMain_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
|
{
|
Total();
|
}
|
|
|
//·µ»ØÐÅÏ¢
|
private void Sub_DataBack()
|
{
|
if (!AllowBack())
|
{
|
MessageBox.Show("²»ÔÊÐíÑ¡Ôñ²»Í¬µÄ" + sPrimaryCol + "£¡", "Ìáʾ");
|
return;
|
}
|
OKTag = Pub_Class.ClsPub.Enum_OKTag.OKTag_OK;
|
this.Visible = false;
|
}
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
timer2.Enabled = false;
|
frmCondition = new frmBillQueryCondition_New();
|
frmCondition.Tag = "";
|
frmCondition.ViewName = ViewName;
|
frmCondition.ModName = ViewName;
|
frmCondition.ShowDialog();
|
if (frmCondition.Tag.ToString() == "OK")
|
{
|
timer1.Enabled = true;
|
}
|
}
|
|
private void grdMain_Paint(object sender, PaintEventArgs e)
|
{
|
GraphicsGrid();
|
}
|
|
private void fh_Click(object sender, EventArgs e)
|
{
|
Sub_DataBack();
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
grdMain.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
}
|
|
}
|
}
|