using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace WorkM
|
{
|
public partial class Sc_MpsResultBill_ICMOSub : Form
|
{
|
public Sc_MpsResultBill_ICMOSub()
|
{
|
InitializeComponent();
|
}
|
|
//³õʼ»¯Íø¸ñ
|
private void initGrid()
|
{
|
DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name);
|
}
|
int HCheckCol = 8; //Ñ¡ÖÐÁÐ
|
int HQtyCol = 7; //ÊýÁ¿ÁÐ
|
|
public long HMPSInterID;
|
public long HSeHInterID;
|
public long HSeHEntryID;
|
public long HDeptID;
|
public long HEmpID;
|
|
public long HMaterID;
|
public double HQty;
|
|
private void grdSub_Show()
|
{
|
grdSub.DataSource = null;
|
grdSub.Columns.Clear();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet Ds1;
|
|
Ds1 = oCn.RunProcReturn("exec h_p_Sc_MpsResultBill_ICMOSubList " + HMaterID + "," + HQty, "h_p_Sc_MpsResultBill_ICMOSubList");
|
grdSub.DataSource = Ds1.Tables[0].DefaultView;
|
|
DataGridViewCheckBoxColumn columncb = new DataGridViewCheckBoxColumn();
|
columncb.HeaderText = "Ñ¡Ôñ";
|
columncb.Name = "cb_check";
|
columncb.TrueValue = true;
|
columncb.FalseValue = false;
|
//column9.DataPropertyName = "IsScienceNature";
|
columncb.DataPropertyName = "IsChecked";
|
grdSub.Columns.Add(columncb);
|
|
HQtyCol = Fun_GetColSub("Éú²úÊýÁ¿");
|
HCheckCol = grdSub.ColumnCount - 1;
|
//¶³½á
|
int FrCol = 0;
|
string s = "";
|
DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name, s, FrCol);
|
grdSub.ReadOnly = false;
|
}
|
|
private void grdSub_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
{
|
if (e.ColumnIndex != HQtyCol)
|
{
|
e.Cancel = true;
|
}
|
}
|
|
private void grdSub_CellClick(object sender, DataGridViewCellEventArgs e)
|
{
|
if (grdSub.CurrentRow == null)
|
return;
|
if (e.ColumnIndex == HCheckCol && DBUtility.ClsPub.isInt(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetColSub("herpclsid")].Value) == 2)
|
{
|
if (DBUtility.ClsPub.isBool(grdSub.Rows[grdSub.CurrentRow.Index].Cells[e.ColumnIndex].Value) == false)
|
{
|
grdSub.Rows[grdSub.CurrentRow.Index].Cells[e.ColumnIndex].Value = true;
|
}
|
else
|
{
|
grdSub.Rows[grdSub.CurrentRow.Index].Cells[e.ColumnIndex].Value = false;
|
}
|
}
|
}
|
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name);
|
}
|
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name);
|
}
|
|
private void cg_Click(object sender, EventArgs e)
|
{
|
string HBillNo;
|
//ÅжÏÓÐûÓÐÑ¡ÖÐÐÐ
|
bool isCheck = false;
|
for (int i = 0; i < grdSub.Rows.Count; i++)
|
{
|
if (DBUtility.ClsPub.isBool(grdSub.Rows[i].Cells[HCheckCol].Value) == true)
|
{
|
//if (DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetColSub("Éú²úÊýÁ¿")].Value) > DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetColSub("δÉêÇëÊýÁ¿")].Value))
|
//{
|
// MessageBox.Show("ÎïÁÏ´úÂ룺" + DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[Fun_GetColSub("ÎïÁÏ´úÂë")].Value) + "²É¹ºÊýÁ¿²»ÄÜ´óÓÚδÉêÇëÊýÁ¿£¡", "Ìáʾ");
|
// return;
|
//}
|
isCheck = true;
|
}
|
}
|
if (isCheck == false)
|
{
|
MessageBox.Show("ûÓÐÑ¡ÔñÐèÒªÉú³ÉÈÎÎñµ¥µÄÎïÁÏ£¡", "Ìáʾ");
|
return;
|
}
|
|
|
|
string HICMOBillNo;
|
string HPPBOMBillNo;
|
SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3();
|
try
|
{
|
HICMOBillNo = DBUtility.Xt_BaseBillFun.get_MaxBillNo_K3("85", oCnK3);
|
HPPBOMBillNo = DBUtility.Xt_BaseBillFun.get_MaxBillNo_K3("88", oCnK3);
|
|
//µÃµ½Óû§ID
|
long HBillerID;
|
DataSet DsBiller;
|
string HSourceBillType = "";
|
DsBiller = oCnK3.RunProcReturn("select top 1 fuserid from t_User where fname='" + DBUtility.ClsPub.CurUserName + "'", "t_User");
|
if (DsBiller.Tables[0].Rows.Count != 0)
|
{
|
HBillerID = DBUtility.ClsPub.isLong(DsBiller.Tables[0].Rows[0][0]);
|
}
|
else
|
{
|
HBillerID = 16394;
|
}
|
//
|
DataSet Ds1;
|
//µÃµ½mainid
|
long HICMOInterID = 0;
|
Ds1 = oCnK3.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNum 'ICMO', @InterID output, 1, " + HBillerID.ToString() + " select ltrim(@InterID)", "GetICMaxNum");
|
if (Ds1.Tables[0].Rows.Count != 0)
|
{
|
HICMOInterID = DBUtility.ClsPub.isLong(Ds1.Tables[0].Rows[0][0]);
|
}
|
if (HICMOInterID == 0)
|
{
|
MessageBox.Show("Éú³ÉÈÎÎñµ¥ÄÚÂëʧ°Ü£¡");
|
return;
|
}
|
|
DataSet Ds2;
|
//µÃµ½mainid
|
long HPPBOMInterID = 0;
|
Ds2 = oCnK3.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNum 'PPBOM', @InterID output, 1, " + HBillerID.ToString() + " select ltrim(@InterID)", "GetICMaxNum");
|
if (Ds2.Tables[0].Rows.Count != 0)
|
{
|
HPPBOMInterID = DBUtility.ClsPub.isLong(Ds2.Tables[0].Rows[0][0]);
|
}
|
if (HPPBOMInterID == 0)
|
{
|
MessageBox.Show("Éú³ÉͶÁϵ¥ÄÚÂëʧ°Ü£¡");
|
return;
|
}
|
|
oCnK3.BeginTran();
|
for (int i = 0; i < grdSub.Rows.Count; i++)
|
{
|
if (DBUtility.ClsPub.isBool(grdSub.Rows[i].Cells[HCheckCol].Value) == true)
|
{
|
long HSubMaterID = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[Fun_GetColSub("hmaterid")].Value);
|
double HSubQty = DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetColSub("Éú²úÊýÁ¿")].Value);
|
//²ÎÊý MPSÄÚÂ룬ÊýÁ¿£¬ÖƵ¥ÈË£¬ÈÎÎñµ¥ÄÚÂ룬ÈÎÎñµ¥ºÅ£¬Í¶Áϵ¥ÄÚÂ룬ͶÁϵ¥ºÅ
|
oCnK3.RunProc("exec h_p_Sc_MpsResultBill_ICMOSub " + HMPSInterID + "," + HSubQty + "," + HBillerID + "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HPPBOMInterID + ",'" + HPPBOMBillNo + "'," + HSubMaterID);
|
|
}
|
}
|
|
oCnK3.Commit();
|
}
|
catch (Exception ex)
|
{
|
oCnK3.RollBack();
|
throw (ex);
|
}
|
|
MessageBox.Show("ÈÎÎñµ¥ºÅ£º" + HICMOBillNo + "£¬Í¶Áϵ¥ºÅ£º" + HPPBOMBillNo + "£¬±£´æÍê±Ï£¡");
|
this.Close();
|
|
}
|
|
private void sx_Click(object sender, EventArgs e)
|
{
|
grdSub_Show();
|
}
|
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private Int32 Fun_GetColSub(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
|
}
|
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
initGrid();
|
grdSub_Show();
|
}
|
}
|
}
|