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 WorkM
|
{
|
public partial class IC_MateOutRequestBillList : Form
|
{
|
public IC_MateOutRequestBillList()
|
{
|
InitializeComponent();
|
}
|
public string ViewName;
|
public string tSQL;
|
public string HInterID;
|
public int icdev; // ͨѶÉ豸±êʶ·û
|
public short st; //º¯Êý·µ»ØÖµ
|
//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 = "";
|
readcard();
|
//string a = "4,7,5,6";
|
//string[] arrStr = a.Split(',');
|
//string sWhere = tSQL; //ÌØÊâÌõ¼þ(ÈÕÆÚÏÞÖÆ£¬²¿ÃÅÏÞÖÆ)
|
//DBUtility.Xt_BaseBillFun.Sub_SQLWhere(ref sWhere);
|
|
//¹ýÂËÌõ¼þ
|
//if (frmCondition.SqlStr.Trim().Length == 0)
|
// return;
|
|
if (DBUtility.ClsPub.isStrNull(HInterID) == "")
|
{
|
MessageBox.Show("Çë¼ì²éÊÇ·ñ·ÅÈ뿨Ƭ»òÕß¿¨Æ¬ÊÇ·ñûÓеǼǣ¡");
|
return;
|
}
|
|
sSql = "select * from h_v_Kf_MateOutRequestBillList where hmainid in (" + HInterID + ") and ×÷·ÏÈË='' and isnull(¹ØÁªÊýÁ¿,0)<ÉêÇëÊýÁ¿";
|
|
|
//
|
DSet = SubCn.RunProcReturn(sSql, "h_v_Kf_MateOutRequestBillList", 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);
|
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 IC_MateOutRequestBillList_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 = this.Name;
|
//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;
|
|
WarM.Kf_MateOutBill_K3 oMateOut = new WarM.Kf_MateOutBill_K3();
|
|
int MainIDCol = Fun_GetCol("hmainid");
|
int SubIDCol = Fun_GetCol("hsubid");
|
for (int i = 0; i < grdMain.SelectedRows.Count;i++ )
|
{
|
DBUtility.BillSelect oSelect = new DBUtility.BillSelect();
|
oSelect.BillMainID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
|
oSelect.BillSubID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[SubIDCol].Value);
|
oMateOut.list.Add(oSelect);
|
}
|
oMateOut.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
|
oMateOut.ROB = true;
|
oMateOut.Sub_OperStatus();
|
//oMateOut.grdStatus = true;
|
oMateOut.ShowDialog();
|
//oMateOut.FillSelectDataIC(list);
|
if (oMateOut.BillChange)
|
{
|
Display();
|
}
|
}
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
timer2.Enabled = false;
|
//frmCondition = new frmBillQueryCondition_New();
|
//frmCondition.Tag = "";
|
//frmCondition.ViewName = ViewName;
|
//frmCondition.ModName = this.Name;
|
//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 cmbDK_Click(object sender, EventArgs e)
|
{
|
Display();
|
}
|
private void readcard()
|
{
|
//--------------Á¬½ÓÉ豸
|
icdev = DBUtility.mwxrf32dll.rf_init(0, 115200);
|
|
if (icdev < 0)
|
{
|
MessageBox.Show("Á¬½Óʧ°Ü!");
|
return;
|
}
|
|
byte[] sRecData = new byte[20];
|
byte[] RecData = new byte[40];
|
byte[] datarecv = new byte[1000];
|
//------------------
|
byte[] key = new byte[10];
|
st = DBUtility.mwxrf32dll.rf_request(icdev, 1, datarecv);
|
if (st != 0)
|
{
|
MessageBox.Show("Çë¼ì²éÊÇ·ñ·ÅÈ뿨Ƭ!");
|
rf_exis();
|
return;
|
}
|
//-----------------------------
|
key[0] = 0xff;
|
key[1] = 0xff;
|
key[2] = 0xff;
|
key[3] = 0xff;
|
key[4] = 0xff;
|
key[5] = 0xff;
|
st = DBUtility.mwxrf32dll.rf_authentication_key(icdev, 0, 1, key);
|
if (st != 0)
|
{
|
MessageBox.Show("M1¿¨ÃÜÂëÈÏ֤ʧ°Ü!");
|
rf_exis();
|
return;
|
}
|
|
//----------------------
|
st = DBUtility.mwxrf32dll.rf_read(icdev, 1, sRecData);
|
if (st != 0)
|
{
|
MessageBox.Show("M1¿¨¶ÁÊý¾Ýʧ°Ü!");
|
rf_exis();
|
return;
|
}
|
string CardNo = Encoding.ASCII.GetString(sRecData);//------------CardNo ¿¨ºÅ
|
rf_exis();
|
CardNo = CardNo.Substring(0, CardNo.IndexOf('\0'));
|
//-----------------------
|
ClsCN oCn = new ClsCN();
|
DataSet Ds;
|
Ds = oCn.RunProcReturn("select * from Kf_MateOutRequestCardNo where hstopflag=0 and hcardno='" + CardNo + "'", "Kf_MateOutRequestCardNo");
|
if (Ds.Tables[0].Rows.Count > 0)
|
{
|
HInterID = "";
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
HInterID = HInterID + Ds.Tables[0].Rows[i]["HInterID"].ToString() + ",";
|
}
|
HInterID = HInterID.Remove(HInterID.LastIndexOf(","), 1);
|
}
|
else
|
{
|
HInterID = "";
|
}
|
}
|
private void rf_exis()
|
{
|
//---------------------¶Ï¿ªÉ豸Á¬½Ó
|
st = DBUtility.mwxrf32dll.rf_exit(icdev);
|
if (st != 0)
|
{
|
MessageBox.Show("¶Ï¿ªÁ¬½Óʧ°Ü!");
|
}
|
else
|
{
|
icdev = 0;
|
//MessageBox.Show("¶Ï¿ªÁ¬½Ó³É¹¦!");
|
}
|
}
|
}
|
}
|