| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- using System;
- using System.Collections;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm
- {
- public partial class ComBaseWell : FrmBase
- {
- private string errMessage = "";
- public ComBaseWell()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- DoQuery();
- break;
- case "Add":
- DoAdd();
- break;
- case "Update":
- DoUpdate();
- break;
- case "Delete":
- DoDelete();
- break;
- case "Resume":
- DoResume();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- string validFlag = "1";
- if (this.ultraCheckEditor1.Checked)
- validFlag = "0";
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseWell.getComBaseWellData", new Object[] { validFlag }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
- SetUltraGridStyle();
- }
- }
- /// <summary>
- ///检查 增加数据
- /// </summary>
- /// <returns></returns>
- private ArrayList CheckAddColumns()
- {
- ArrayList list = new ArrayList();
- string wellCode = this.ultraTextEditor1.Text.Trim().ToString();
- if (wellCode.Length == 0 || wellCode.Length > 20 || !StringUtil.IsOnlyLetterAndDigit(wellCode))
- {
- errMessage = "产能井代码:1-20位有效数字与字母组成";
- return null;
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseWell.checkComBaseWell", new Object[] { wellCode }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- errMessage = "存在相同的产能井代码";
- return null;
- }
- string wellName = this.ultraTextEditor2.Text.Trim().ToString();
- if (wellName.Length == 0 || wellName.Length > 100)
- {
- errMessage = "产能井代码:1-50字母或者汉字组成";
- return null;
- }
- string weight = this.ultraTextEditor3.Text.Trim().ToString();
- if (weight.Length == 0 || !StringUtil.IsNumber(weight))
- {
- errMessage = "最大产能:数字组成,不能为空";
- return null;
- }
- string memo = this.ultraTextEditor4.Text.Trim().ToString();
- string userName = UserInfo.GetUserName();
- list.Add(wellCode);
- list.Add(wellName);
- list.Add(weight);
- list.Add(memo);
- list.Add(userName);
- return list;
- }
- /// <summary>
- /// 增加
- /// </summary>
- private void DoAdd()
- {
- ArrayList listParams = CheckAddColumns();
- if (listParams == null)
- {
- MessageBox.Show(errMessage, "提示");
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.addComBaseWell", new Object[] { listParams }, this.ob);
- if (count > 0)
- {
- DoQuery();
- }
- }
- private ArrayList CheckUpdate()
- {
- ArrayList list = new ArrayList();
- string wellName = this.ultraTextEditor2.Text.Trim().ToString();
- if (wellName.Length == 0 || wellName.Length > 100)
- {
- errMessage = "产能井代码:1-50字母或者汉字组成";
- return null;
- }
- string weight = this.ultraTextEditor3.Text.Trim().ToString();
- if (weight.Length == 0 || !StringUtil.IsNumber(weight))
- {
- errMessage = "最大产能:数字组成,不能为空";
- return null;
- }
- string memo = this.ultraTextEditor4.Text.Trim().ToString();
- string userName = UserInfo.GetUserName();
- string wellCode = this.ultraTextEditor1.Text.Trim().ToString();
- if (wellCode.Length == 0 || wellCode.Length > 20 || !StringUtil.IsOnlyLetterAndDigit(wellCode))
- {
- errMessage = "产能井代码:1-20位有效数字与字母组成";
- return null;
- }
- DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseWell.checkComBaseWell", new Object[] { wellCode }, this.ob);
- if (dt == null || dt.Rows.Count == 0)
- {
- errMessage = "不存在的产能井代码";
- return null;
- }
- list.Add(wellName);
- list.Add(weight);
- list.Add(memo);
- list.Add(userName);
- list.Add(wellCode);
- return list;
- }
- /// <summary>
- /// 修改
- /// </summary>
- private void DoUpdate()
- {
- ArrayList listParams = CheckUpdate();
- if (listParams == null)
- {
- MessageBox.Show(errMessage, "提示");
- return;
- }
- string wellCode = this.ultraTextEditor1.Text.Trim().ToString();
- int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.updateBaseWell", new Object[] { listParams }, this.ob);
- if (count > 0)
- {
- DoQuery();
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (row.Cells["WELL_CODE"].Value.ToString().Equals(wellCode))
- {
- row.Activate();
- break;
- }
- }
- }
- else
- {
- MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- private void DoDelete()
- {
- if (MessageBox.Show("删除记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- string wellCode = ultraTextEditor1.Text.Trim().ToString();
- string deleteName = UserInfo.GetUserName();
- string validflag = ultraGrid1.DisplayLayout.ActiveRow.Cells["VALIDFLAGNAME"].Text.Trim().ToString();
- if (wellCode.Length == 0 || validflag.Equals("无效"))
- {
- MessageBox.Show("请选取删除有效记录或者请输入删除人!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.deleteComBaseWell", new Object[] { deleteName, wellCode }, this.ob);
- if (count > 0)
- {
- DoQuery();
- SetActiveRow(wellCode);
- }
- else
- {
- MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- }
- /// <summary>
- /// 恢复数据
- /// </summary>
- private void DoResume()
- {
- if (MessageBox.Show("恢复记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- return;
- }
- string wellCode = ultraTextEditor1.Text.Trim().ToString();
- string validflag = ultraGrid1.DisplayLayout.ActiveRow.Cells["VALIDFLAGNAME"].Text.Trim().ToString();
- if (wellCode.Length == 0 || validflag.Equals("有效"))
- {
- MessageBox.Show("请选取需要恢复的无效记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.resumeComBaseWell", new Object[] { wellCode }, this.ob);
- if (count > 0)
- {
- DoQuery();
- SetActiveRow(wellCode);
- }
- else
- {
- MessageBox.Show("恢复失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- }
- /// <summary>
- /// 激活行编辑区赋值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- this.ultraTextEditor1.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["WELL_CODE"].Text.ToString();
- this.ultraTextEditor2.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["WELL_NAME"].Text.ToString();
- this.ultraTextEditor3.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["WEIGHT"].Text.ToString();
- this.ultraTextEditor4.Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["MEMO"].Text.ToString();
- }
- /// <summary>
- /// 设置ultraGrid1行颜色
- /// </summary>
- private void SetUltraGridStyle()
- {
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow row = ultraGrid1.Rows[i];
- if (!row.Cells["VALIDFLAGNAME"].Value.ToString().Equals("有效"))
- {
- row.Appearance.ForeColor = Color.Red;
- }
- else
- {
- row.Appearance.ForeColor = Color.Black;
- }
- }
- }
- private void SetActiveRow(string wellCode)
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- row = ultraGrid1.Rows[i];
- if (row.Cells["WELL_CODE"].Value.ToString().Equals(wellCode))
- {
- row.Activate();
- break;
- }
- }
- }
- ///// <summary>
- ///// 操作数项
- ///// </summary>
- ///// <returns></returns>
- //private ComBaseWellObject GetOptionData()
- //{
- // ComBaseWellObject cbw = new ComBaseWellObject();
- // cbw.WellCode = ultraTextEditor1.Text.Trim().ToString();
- // cbw.WellName = ultraTextEditor2.Text.Trim().ToString();
- // cbw.Weight = ultraTextEditor3.Text.Trim().ToString();
- // cbw.Memo = ultraTextEditor4.Text.Trim().ToString();
- // return cbw;
- //}
- //private void DoAdd1()
- //{
- // ComBaseWellObject cbw = GetOptionData();
- // cbw.CreateName = UserInfo.GetUserName();
- // cbw.CreateTime = System.DateTime.Now.ToString();
- // int count = ServerHelper.SetData("com.steering.pss.qcm.ComBaseWell.addComBaseWell1", new Object[] { JSONFormat.Format(cbw) }, this.ob);
- //}
- }
- }
|