ÿþusing System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Pub_Class; namespace WorkM { public partial class Xs_SendGoodsPlan_CF : Form { public Xs_SendGoodsPlan_CF() { InitializeComponent(); } DateTimePicker dtp = new DateTimePicker();  //ُ̑ž[‹OSN*NDateTimePicker§cöN  Rectangle _Rectangle; public string[,] row=new string[60,2]; ClsGridViewSum oSumGrid = new ClsGridViewSum(); //š[INR // public const Int16 HTagCol = 0; public const Int16 HSnoCol = 1; public const Int16 HDateCol = 2; public const Int16 HQtyCol = 3; // public bool isOk; public int sHDateCol; public int sHQtyCol; public bool grdStatus=true; //RËYSQf:y   dtp.Format = DateTimePickerFormat.Custom;  //¾‹nåegeöeô•§cöN„v£NR private void grdMain_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == HDateCol) { _Rectangle = grdMain.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); //—_0R@b(WUSCQf:y§cöN†N   } else dtp.Visible = false; } //S_R„v½[¦^ØSSöe ÿöeô•§cöNHQ–Ï…weg ÿ N6qUSCQe‹NöN { EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown); this.EditingControl = null; } } DataGridViewTextBoxEditingControl EditingControl; private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e) { // if (!grdStatus) { return; } DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); // //if (oSumGrid.Changelock) // return; //if(oSumGrid.EditStatus) //{ //if (!CheckGridRow(oSumGrid.OldCell.Row)) // return; //} } private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (grdMain.CurrentCell != null) { if (e.Control is DataGridViewTextBoxEditingControl) { this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control; //žX RÔYXbYt this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown); } } } private void EditingControl_KeyDown(object sender, KeyEventArgs e) { //N¡RYt //Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl); } private void bc_Click(object sender, EventArgs e) { //1Y»S&q¹p label4.Focus(); if (!AllowSave()) { return; } isOk = true; sHDateCol = HDateCol; sHQtyCol = HQtyCol; this.Close(); } //ÝOX[MR Àhåg private bool AllowSave() { double HQty = 0; DateTime HMaxDate = DBUtility.ClsPub.isDate(DBUtility.ClsPub.GetServerDate(0)).AddDays(59); DateTime HMinDate = DBUtility.ClsPub.isDate(DBUtility.ClsPub.GetServerDate(0)); for (int i = 0; i < grdMain.Rows.Count; i++) { if (DBUtility.ClsPub.isStrNull( grdMain.Rows[i].Cells[HDateCol].Value) != "") { if (IsDate(grdMain.Rows[i].Cells[HDateCol].Value.ToString()) == false) { MessageBox.Show(",{" + (i + 1) + "Lˆ ÿåeg HMaxDate) { MessageBox.Show(",{" + (i + 1) + "Lˆ ÿåeg Ný€'YŽN" + HMaxDate.ToShortDateString() + "ÿ", "Ðc:y"); return false; } if (DBUtility.ClsPub.isDate(grdMain.Rows[i].Cells[HDateCol].Value) < HMinDate) { MessageBox.Show(",{" + (i + 1) + "Lˆ ÿåeg Ný€\ŽN" + HMinDate.ToShortDateString() + "ÿ", "Ðc:y"); return false; } for (int j = i+1; j < grdMain.Rows.Count; j++) { if (DBUtility.ClsPub.isDate(grdMain.Rows[i].Cells[HDateCol].Value) == DBUtility.ClsPub.isDate(grdMain.Rows[j].Cells[HDateCol].Value)) { MessageBox.Show(",{" + (i + 1) + "LˆN,{" + (j + 1) + "Lˆåegøv Tÿ", "Ðc:y"); return false; } } HQty = HQty + DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[HQtyCol].Value); } } if (DBUtility.ClsPub.isDoule(txtHQty.Text) != HQty) { MessageBox.Show("ÆbRpeϑN¢‹US;`peϑ NNôÿ", "Ðc:y"); return false; } return true; } public bool IsDate(string strDate) { string sDateType; if (strDate.IndexOf("-") != -1) { sDateType = "yyyy-M-d"; } else if (strDate.IndexOf("/") != -1) { sDateType = "yyyy/M/d"; } else { sDateType = "yyyyMMdd"; } try { //DateTime.Parse(strDate); DateTime dt = DateTime.ParseExact(strDate, sDateType, System.Globalization.CultureInfo.InvariantCulture); return true; } catch { return false; } } private void tc_Click(object sender, EventArgs e) { isOk = false; this.Close(); } private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; //RËYS initGrid(); DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); for (int i = 0; i < 60; i++) { if (DBUtility.ClsPub.isStrNull(row[i, 0]) != "") { string a = DBUtility.ClsPub.isStrNull(row[i, 0]); string b = DBUtility.ClsPub.isStrNull(row[i, 1]); grdMain.Rows[i].Cells[HDateCol].Value = a; grdMain.Rows[i].Cells[HQtyCol].Value = b; } else { break; } } } private void DelRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.DelRow(oSumGrid); } private void Xs_SendGoodsPlan_CF_Load(object sender, EventArgs e) { oSumGrid.NoCol = HSnoCol; oSumGrid.ogrdMain = grdMain; oSumGrid.oGridsum = grdSum; } private void AddRow_Click(object sender, EventArgs e) { DBUtility.Xt_BaseBillFun.AddRow(oSumGrid); } } }