using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using System.Net; using System.Collections; using CoreFS.SA06; namespace Core.StlMes.Client.BuyBillet { public partial class FrmBuyDCYB : FrmBase { private new CoreFS.CA06.OpeBase ob = new OpeBase(); public string OrderID { get; set; } public FrmBuyDCYB(OpeBase ops) { ob = ops; InitializeComponent(); } private void FrmBuyDCYB_Load(object sender, EventArgs e) { Initial_Data(); } private void Initial_Data() { txt_dhrq.Value = DateTime.Now.ToString("yyyy-MM-dd"); txt_order_no.Text = OrderID; Bind_Grid(); RefreshAndAutoSize(this.ultraGrid1); } private void ultraNumericEditor1_ValueChanged(object sender, EventArgs e) { } private void txt_count_ValueChanged(object sender, EventArgs e) { } private void ultraButton1_Click(object sender, EventArgs e) { string stove_no = txt_stove.Value.ToString(); string judge_stove_no = txt_judge_stove.Value.ToString(); string plan_count = txt_count.Value.ToString(); string plan_weight = txt_weight.Value.ToString(); string dhrq = txt_dhrq.Text.ToString(); string create_name = this.UserInfo.GetUserName(); string ord_pk = this.OrderID; ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.insertBUY_CGP_DCYB", new object[] { stove_no,judge_stove_no,plan_count,plan_weight,dhrq,create_name,ord_pk }, this.ob); MessageBox.Show("新增成功!"); Bind_Grid(); clear_Form(); RefreshAndAutoSize(this.ultraGrid1); } private void Bind_Grid() { DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.getBUY_CGP_DCYB", new object[] { OrderID }, this.ob); DataTable dt3 = dataSet1.Tables[0]; GridHelper.CopyDataToDatatable(dt, dt3, true); } public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid) { try { ultraGrid.DataBind(); foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands) { foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns) { column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand); } } ultraGrid.Refresh(); } catch { } } private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; SetRowValueToForm(row); } private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { } private void SetRowValueToForm(UltraGridRow row) { txt_stove.Text = row.Cells["炉号"].Value.ToString(); txt_judge_stove.Text = row.Cells["判定炉号"].Value.ToString(); txt_count.Value = row.Cells["支数"].Value; txt_weight.Value = row.Cells["吨数"].Value; txt_dhrq.Value = row.Cells["到货日期"].Value; txt_dcyb_pk.Text = row.Cells["DCYB_PK"].Value.ToString() ; } private void btn_update_Click(object sender, EventArgs e) { string stove_no = txt_stove.Value.ToString(); string judge_stove_no = txt_judge_stove.Value.ToString(); string plan_count = txt_count.Value.ToString(); string plan_weight = txt_weight.Value.ToString(); string dhrq = txt_dhrq.Text.ToString(); string create_name = this.UserInfo.GetUserName(); string dcyb_pk = txt_dcyb_pk.Text; ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.updateBUY_CGP_DCYB", new object[] { stove_no, judge_stove_no, plan_count, plan_weight, dhrq, create_name, dcyb_pk }, this.ob); MessageBox.Show("保存成功!"); Bind_Grid(); clear_Form(); } private void btn_delete_Click(object sender, EventArgs e) { string dcyb_pk = txt_dcyb_pk.Text; string stove_no = txt_stove.Text; if (MessageBox.Show("删除炉号 "+stove_no+"?","删除确认", MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK) { ServerHelper.SetData("com.steering.pss.buybillet.Buybillet.deleteBUY_CGP_DCYB", new object[] { dcyb_pk }, this.ob); MessageBox.Show("删除成功!"); Bind_Grid(); clear_Form(); } } private void clear_Form() { txt_judge_stove.Text = string.Empty; txt_stove.Text = string.Empty; txt_weight.Value = null; txt_count.Value = null; } private void ultraGrid1_Click(object sender, EventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; SetRowValueToForm(row); } } }