| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 |
- using System;
- using System.Collections.Generic;
- using System.Collections;
- using System.ComponentModel;
- using System.IO;
- using System.Diagnostics;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Core.Mes.Client.Common;
- namespace Core.LgMes.Client.LgIntegrationQuery
- {
- public partial class frmSchedulingShift : Core.Mes.Client.Common.frmStyleBase
- {
- bool blChange = false; //判断是否发生变化。
- string ShiftCode = "";
- public frmSchedulingShift()
- {
- InitializeComponent();
- }
- private void frmSchedulingShift_Load(object sender, EventArgs e)
- {
- //初始化时间和查询条件
- this.uldtBeginTime.Value = DateTime.Today.AddDays(-7).ToString("yyyy-MM-dd") + " 00:00";
- this.uldtEndTime.Value = DateTime.Today.ToString("yyyy-MM-dd") + " 23:59"; ;
- this.cmbxShiftQuery.Enabled = false;
- ckbTime.Checked = true;
- this.uldtBeginTime.Enabled = true;
- this.uldtEndTime.Enabled = true;
- this.ultxtMan.Text =this.UserInfo.GetUserName();
- string strErr = "";
- ShiftCode = "";
-
- ArrayList arry = new ArrayList();
- arry.Add("GetCurrDuty.Select");
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
- "doSimpleQuery", arry, out strErr);
- ShiftCode=ds.Tables[0].Rows[0][0].ToString();
- if (!string.IsNullOrEmpty(ShiftCode))
- {
- cmbxShift.SelectedIndex = Convert.ToInt16(ShiftCode.Substring(1, 1)) - 1;
- }
-
- //获取原有调度信息
- QueryShiftData();
- //其他岗位只有查询功能的限制
- if (this.Key.Contains("@Query") == true)
- {
- ultraExpandableGroupBox1.Visible = false;
- }
- }
- private void ckbTime_CheckedChanged(object sender, EventArgs e)
- {
- uldtBeginTime.Enabled = ckbTime.Checked;
- uldtEndTime.Enabled = ckbTime.Checked;
- }
- private void chkShift_CheckedChanged(object sender, EventArgs e)
- {
- cmbxShiftQuery.Enabled = chkShift.Checked;
- if (chkShift.Checked == true)
- {
- string ShiftCode = "", strErr="";
- ArrayList arry = new ArrayList();
- arry.Add("GetCurrDuty.Select");
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
- "doSimpleQuery", arry, out strErr);
- ShiftCode = ds.Tables[0].Rows[0][0].ToString();
- if (!string.IsNullOrEmpty(ShiftCode))
- {
- cmbxShiftQuery.SelectedIndex = Convert.ToInt16(ShiftCode.Substring(1, 1)) - 1;
- }
- }
- else
- {
- cmbxShiftQuery.Text = "";
- }
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Add":
- if (MessageBox.Show("你确认要增加调度交接班信息?", "提示", System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- if (string.IsNullOrEmpty(ultxtMan.Text))
- {
- MessageBox.Show("请输入交班人!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else if (string.IsNullOrEmpty(cmbxShift.Text))
- {
- MessageBox.Show("请选择班次!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else if (string.IsNullOrEmpty(txtContent.Text))
- {
- MessageBox.Show("请输入交班的内容!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- AddShiftData();
- }
- break;
- case "Delete":
- if (ultraGrid.ActiveRow!=null)
- {
- System.Windows.Forms.DialogResult t = MessageBox.Show("你确认要删除所选择的行?", "提示", System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (t == System.Windows.Forms.DialogResult.Yes)
- {
- DeleteShiftData();
- }
- }
- else
- {
- MessageBox.Show("请选择你要删除的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- break;
- case "Update":
- if (MessageBox.Show("你确认要修改调度交接班信息?", "提示", System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- if (ultraGrid.ActiveRow != null)
- {
- UpdateShiftData();
- }
- else
- {
- MessageBox.Show("请选择你要修改的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- break;
- case "Query":
- QueryShiftData();
- break;
- case "Export":
- if (ultraGrid.Rows.Count > 0)
- {
- ExportExcel();
- }
- else
- MessageBox.Show("没有交班信息。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- break;
- case "Exit":
- this.Close();
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// 获取调度交班信息
- /// </summary>
- private void QueryShiftData()
- {
- string strShift = "";
- string strStartTime = "";
- string strEndTime = "";
- string strErr = "";
- if (ckbTime.Checked == true)
- {
- if (Convert.ToDateTime(uldtBeginTime.Value) > Convert.ToDateTime(uldtEndTime.Value))
- {
- MessageBox.Show("时间条件的开始时间不能大于结束时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- else
- {
- strStartTime = this.uldtBeginTime.DateTime.ToString("yyyy-MM-dd");
- strEndTime = this.uldtEndTime.DateTime.ToString("yyyy-MM-dd");
- }
- }
- if (chkShift.Checked == true)
- {
- strShift = Convert.ToString(cmbxShiftQuery.SelectedIndex+1);
- }
- ArrayList arry = new ArrayList();
- arry.Add("QueryShiftData.select");
- arry.Add(strStartTime);
- arry.Add(strEndTime);
- arry.Add(strShift);
- arry.Add(strShift);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
- "doSimpleQuery", arry, out strErr);
- dataSet1.Clear(); //清空原有行
- if (strErr =="" && ds != null)
- {
- if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
- {
- foreach (DataRow Dr in ds.Tables[0].Rows)
- {
- DataRow dr1 = dataSet1.Tables[0].NewRow();
- dr1["ID"] = Dr["ID"].ToString();
- dr1["SHIFTNAME"] = Dr["SHIFTNAME"].ToString();
- dr1["SHIFT"] = Dr["SHIFT"].ToString();
- dr1["SHIFTCONTENT"] = Dr["SHIFTCONTENT"].ToString();
- dr1["SHIFTDATE"] = Dr["SHIFTDATE"].ToString();
- dataSet1.Tables[0].Rows.Add(dr1);
- }
- }
- }
- }
- /// <summary>
- /// 增加调度交班信息
- /// </summary>
- private void AddShiftData()
- {
-
- string strShift ="";
- if (cmbxShift.SelectedIndex == 0)
- strShift = "1";
- else if (cmbxShift.SelectedIndex == 1)
- strShift = "2";
- else if (cmbxShift.SelectedIndex == 2)
- strShift = "3";
- else if (cmbxShift.SelectedIndex == 3)
- strShift = "4";
- string strShiftContent = txtContent.Text;
- string strShiftTime = DateTime.Now.ToString();
- string strShiftName = ultxtMan.Text;
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("AddShiftData.select");
- arry.Add(strShiftName);
- arry.Add(strShift);
- arry.Add(strShiftContent);
- arry.Add(strShiftTime);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- if (strErr != "")
- {
- MessageBox.Show("保存失败!调度信息新增失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- MessageBox.Show("调度信息新增成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- QueryShiftData();
- }
- }
- /// <summary>
- /// 删除交班调度信息
- /// </summary>
- private void DeleteShiftData()
- {
- if (ultraGrid.ActiveRow != null)
- {
- string strId = ultraGrid.ActiveRow.Cells["ID"].Value.ToString();
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("DeleteShiftData.select");
- arry.Add(strId);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- if (strErr != "")
- {
- MessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- MessageBox.Show("交班调度信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- QueryShiftData();
- ultxtMan.Text = "";
- cmbxShift.Text = "";
- ShiftTime.Text = "";
- txtContent.Text = "";
- }
- }
- }
- /// <summary>
- /// 选择要编辑的信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid_Click(object sender, EventArgs e)
- {
- DialogResult dlgR = DialogResult.None;
- if (ultraGrid.ActiveRow == null || ultraGrid.ActiveRow.Index < 0)
- {
- return;
- }
- else if (ultraGrid.ActiveRow.Index >= 0)
- {
- if (blChange == true && txtContent.Text.Trim().Length > 0)
- dlgR = MessageBox.Show("调度交班信息已更新请先增加或修改操作!", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
- if (dlgR == DialogResult.Yes || dlgR == DialogResult.Cancel) return;
- blChange = false;
- ultxtMan.Text = ultraGrid.ActiveRow.Cells["SHIFTNAME"].Value.ToString();
- cmbxShift.Text = ultraGrid.ActiveRow.Cells["SHIFT"].Text;
- ShiftTime.Text = ultraGrid.ActiveRow.Cells["SHIFTDATE"].Value.ToString();
- txtContent.Text = ultraGrid.ActiveRow.Cells["SHIFTCONTENT"].Value.ToString();
-
- }
- }
- /// <summary>
- /// 修改调度交班信息
- /// </summary>
- private void UpdateShiftData()
- {
- if (ultraGrid.ActiveRow != null)
- {
- string strShift = "";
- if (cmbxShift.SelectedIndex == 0)
- strShift = "1";
- else if (cmbxShift.SelectedIndex == 1)
- strShift = "2";
- else if (cmbxShift.SelectedIndex == 2)
- strShift = "3";
- else if (cmbxShift.SelectedIndex == 3)
- strShift = "4";
- string strId = ultraGrid.ActiveRow.Cells["ID"].Value.ToString();
- string strShiftName = ultxtMan.Text;
- string strShiftContent = txtContent.Text;
- string strShiftTime = DateTime.Now.ToString();
- string strErr = "";
-
- ArrayList arry = new ArrayList();
- arry.Add("UpdateShiftData.select");
- arry.Add(strShiftName);
- arry.Add(strShift);
- arry.Add(strShiftContent);
- arry.Add(strId);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- if (strErr != "")
- {
- MessageBox.Show("调度交班信息修改失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- MessageBox.Show("调度交班信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- QueryShiftData();
- }
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- private void ExportExcel()
- {
- try
- {
- string StrfileName = System.Windows.Forms.Application.StartupPath + "\\Report\\调度交班信息.xls";
- this.ultraGridExcelExporter1.Export(this.ultraGrid, StrfileName);
- ProcessStartInfo p = new ProcessStartInfo(StrfileName);
- p.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
- p.WorkingDirectory = Path.GetDirectoryName(StrfileName);
- Process.Start(p);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void txtContent_TextChanged(object sender, EventArgs e)
- {
- //if (txtContent.Text.Trim().Length > 0)
- // blChange = true;
- }
- private void butClear_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("是否要清空交接班信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
- {
- this.ultxtMan.Text = this.UserInfo.GetUserName();
- if (!string.IsNullOrEmpty(ShiftCode))
- {
- cmbxShift.SelectedIndex = Convert.ToInt16(ShiftCode.Substring(1, 1)) - 1;
- }
- ShiftTime.Value = DateTime.Now;
- txtContent.Clear();
- }
- }
- private void txtContent_KeyPress(object sender, KeyPressEventArgs e)
- {
- if(txtContent.Text.Trim().Length>0)
- blChange = true;
- }
- }
- }
|