Esempio n. 1
0
 private void rbtn_deleteUser_Click(object sender, EventArgs e)
 {
     try
     {
         int p = rgv_users.SelectedRows[0].Index;
         if (p < 0)
         {
             return;
         }
         DialogResult dr = MessageBox.Show(message[4], message[3], MessageBoxButtons.OKCancel);
         if (dr == DialogResult.OK)
         {
             db.User.Remove(user_list[p]);//移除当前元素
             db.SaveChanges();
             user_list.RemoveAt(p);
             this.rgv_users.Rows.Clear();
             //设置RadGridView信息及赋值
             for (int i = 0; i < user_list.Count; i++)
             {
                 this.rgv_users.Rows.AddNew();
                 this.rgv_users.Rows[i].Cells[0].Value = user_list[i].username;                                                                 //用户名
                 this.rgv_users.Rows[i].Cells[1].Value = user_list[i].realName;                                                                 //真实姓名
                 this.rgv_users.Rows[i].Cells[2].Value = user_list[i].PermissionId == 1 ? "工程师" : user_list[i].PermissionId == 2 ? "司钻" : "游客"; //权限
             }
         }
     }
     catch { }
 }
Esempio n. 2
0
 private void rbtn_addWorker_Click(object sender, EventArgs e)
 {
     try
     {
         AddWorkerForm add = new AddWorkerForm();
         add.list_type = list_type; //传递工种类型
         add.db        = db;
         add.editType  = 0;         //新增
         add.ShowDialog();
         if (add.isEdit)
         {
             worker_list.Add(add.worker);
             db.Worker.Add(add.worker);
             db.SaveChanges();
             //刷新表
             this.rgv_workers.Rows.Clear();
             //设置RadGridView信息及赋值
             for (int i = 0; i < worker_list.Count; i++)
             {
                 this.rgv_workers.Rows.AddNew();
                 this.rgv_workers.Rows[i].Cells[0].Value = worker_list[i].Name;                                                                            //姓名
                 this.rgv_workers.Rows[i].Cells[1].Value = add.list_type.Where(o => o.ID == worker_list[i].TypeWork).Select(o => o.Type).FirstOrDefault(); //工种名
                 this.rgv_workers.Rows[i].Cells[2].Value = worker_list[i].EmpNO;                                                                           //姓名
             }
         }
     }
     catch { }
 }
Esempio n. 3
0
 //添加DoWork事件请求数据
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         UserTagRef = db.UserTagRef.Where(o => /*o.DrillId == AppDrill.DrillID &&*/ o.Username == AppDrill.username).FirstOrDefault();
         if (UserTagRef != null)
         {
             if (UserTagRef.JsonTag != null)
             {
                 UserTag = new JavaScriptSerializer().Deserialize <List <UserTag> >(UserTagRef.JsonTag); //反序列化
             }
         }
         else
         {
             UserTagRef model = new UserTagRef();
             DateTime   dt    = DateTime.Now;
             model.DrillId      = AppDrill.DrillID;
             model.Username     = AppDrill.username;
             model.dataMakePGM  = "SelectTagForm";
             model.dataMakeTime = dt;
             model.dataMakeUser = AppDrill.realName;
             model.dataUpdPGM   = "SelectTagForm";
             model.dataUpdTime  = dt;
             model.dataUpdUser  = AppDrill.realName;
             db.UserTagRef.Add(model);
             db.SaveChanges();
         }
         TagList     = db.DrillTag.Where(o => o.DrillId == 1).ToList();
         list_tagdir = db.TagDictionary.Where(o => o.TransferType == AppDrill.language).ToList();//取出Tag字典表中的数据
         btnlist     = new List <Button>();
     }
     catch { }
 }
Esempio n. 4
0
        private void saveMemo(string strValue, long lTime)
        {
            Memo memoModel = new Memo();

            if (null == memoModel)
            {
                return;
            }

            memoModel.Text         = strValue;
            memoModel.Tag          = "var2";
            memoModel.Value        = getDepthValue(lTime);
            memoModel.UnixTime     = Convert.ToInt32(lTime);
            memoModel.CreateTime   = DateTime.Now;
            memoModel.DrillID      = m_iDrillID;
            memoModel.dataMakePGM  = "Hand";
            memoModel.dataMakeTime = DateTime.Now;
            memoModel.dataMakeUser = AppDrill.username;
            memoModel.dataUpdPGM   = "Hand";
            memoModel.dataUpdTime  = DateTime.Now;
            memoModel.dataUpdUser  = AppDrill.username;

            _db.Memo.Add(memoModel);
            _db.SaveChanges();
        }
Esempio n. 5
0
        private void rtxt_type_Click(object sender, EventArgs e)
        {
            SelectList sl = new SelectList();

            sl.isWhat = 5;
            sl.ShowDialog();
            try
            {
                list_type = db.WorkType.ToList();
                if (sl.selectText != null)
                {
                    WorkType wt = list_type.Where(o => o.Type == sl.selectText).FirstOrDefault();
                    if (wt == null)
                    {
                        wt              = new WorkType();
                        wt.Type         = sl.selectText;
                        wt.dataMakePGM  = "AddWorker";
                        wt.dataMakeTime = DateTime.Now;
                        wt.dataMakeUser = AppDrill.username;
                        wt.dataUpdPGM   = "AddWorker";
                        wt.dataUpdTime  = DateTime.Now;
                        wt.dataUpdUser  = AppDrill.username;
                        db.WorkType.Add(wt);
                        list_type.Add(wt);
                        db.SaveChanges();
                    }
                    this.rtxt_type.Text = sl.selectText;
                }
            }
            catch { }
        }
Esempio n. 6
0
 private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         _db.SaveChanges();
     }
     catch { }
 }
Esempio n. 7
0
 private void LoginForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     using (_db = new DrillOSEntities())
     {
         var item = _db.User.Where(o => o.username == AppDrill.username).FirstOrDefault();
         item.isActive = false;
         _db.SaveChanges();
     }
 }
Esempio n. 8
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            int i = radGridView1.SelectedRows[0].Index;//找到当前选中行的索引

            unix = (long)Memo[i].UnixTime;
            db.Memo.Remove(Memo[i]);                                                                                                                               //移除当前选中行
            db.SaveChanges();
            Memo = db.Memo.Where(o => o.DrillID == AppDrill.DrillID && o.dataMakeUser == AppDrill.username).OrderByDescending(o => o.UnixTime).Take(200).ToList(); //取前200条数据
        }
Esempio n. 9
0
        //添加DoWork事件请求数据
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            var AlarmHistory = db.AlarmHistory.Where(o => o.RecoveryTime == null && o.DrillId == AppDrill.DrillID).ToList();

            //修改报警状态
            foreach (AlarmHistory alarm in AlarmHistory)//listAlarm
            {
                alarm.Dispose      = 1;
                alarm.DisposeMan   = AppDrill.realName;
                alarm.DisposeTime  = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                alarm.RecoveryTime = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            db.SaveChanges();
        }
Esempio n. 10
0
        private void saveDrill()
        {
            #region 保存信息
            try
            {
                var data = _db.Drill.Where(p => p.DrillNo == rdp_wellNo.SelectedItem.Text).FirstOrDefault();
                data.Lease       = txt_lease.Text;
                data.Contractor  = txt_contractor.Text;
                data.Operator    = txt_operator.Text;
                data.RigNo       = txt_rignum.Text;
                data.Country     = txt_country.Text;
                data.DateSpud    = datetimepickerspud.Value.ToString();
                data.dataUpdTime = DateTime.Now;

                if (string.IsNullOrEmpty(data.DateRelease))
                {
                    data.DateRelease = datetimepickerrelease.Value.ToString();
                }

                //构建经纬度字符串
                string weidusymbol, jingdusymbol;
                if (rbtn_laN.Checked)
                {
                    weidusymbol = "N";
                }
                else
                {
                    weidusymbol = "S";
                }
                if (rbtn_longW.Checked)
                {
                    jingdusymbol = "W";
                }
                else
                {
                    jingdusymbol = "E";
                }

                string weidu     = weidusymbol + txt_lade.Text + "-" + txt_lamin.Text + "-" + txt_lase.Text;
                string jingdu    = jingdusymbol + txt_longde.Text + "-" + txt_longmin.Text + "-" + txt_longse.Text;
                string jingweidu = weidu + "," + jingdu;
                data.location = jingweidu;
                _db.SaveChanges();
            }
            catch
            {
            }
            #endregion
        }
Esempio n. 11
0
        private void OK_Click(object sender, EventArgs e)
        {
            switch (TabelName)
            {
            case "BitRecord":
                if (BitRecordList != null)
                {
                    this.BitRecord = BitRecordList[gvw_selectTable.CurrentRow.Index];
                }
                break;

            case "DrillAsmb":
                if (!string.IsNullOrEmpty(txt_NO.Text) && !string.IsNullOrEmpty(txt_item.Text) && !string.IsNullOrEmpty(txt_length.Text))
                {
                    Table_DrillingAssembly td = new Table_DrillingAssembly();
                    td.CodeNo       = txt_NO.Text;
                    td.Item         = txt_item.Text;
                    td.Length       = txt_length.Text;
                    td.dataMakePGM  = "Add";
                    td.dataMakeTime = DateTime.Now;
                    td.dataMakeUser = AppDrill.username;
                    td.dataUpdPGM   = "Add";
                    td.dataUpdTime  = DateTime.Now;
                    td.dataUpdUser  = AppDrill.username;
                    db.Table_DrillingAssembly.Add(td);
                    db.SaveChanges();
                    this.DrillingAssembly = td;
                }
                else if (DrillingAssemblyList != null)
                {
                    this.DrillingAssembly = DrillingAssemblyList[gvw_selectTable.CurrentRow.Index];
                }
                break;
            }
            this.Close();
        }
Esempio n. 12
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(txt_box1.Text))
                {
                    this.selectText = txt_box1.Text;
                    switch (isWhat)
                    {
                    case 1:
                        BushingSize bs = bsize.Where(o => o.Size == selectText).FirstOrDefault();
                        if (bs == null)
                        {
                            bs              = new BushingSize();
                            bs.Size         = selectText;
                            bs.dataMakePGM  = "AddBushingSize";
                            bs.dataMakeTime = DateTime.Now;
                            bs.dataMakeUser = AppDrill.username;
                            bs.dataUpdPGM   = "AddBushingSize";
                            bs.dataUpdTime  = DateTime.Now;
                            bs.dataUpdUser  = AppDrill.username;
                            db.BushingSize.Add(bs);
                            db.SaveChanges();
                        }
                        break;

                    case 4:
                        DateTime dt = DateTime.Now;
                        Table_MudChemicalsAdded model = MudChemicalsAdded.Where(o => o.Item == txt_box1.Text).FirstOrDefault();
                        if (model == null)
                        {
                            model              = new Table_MudChemicalsAdded();
                            model.Item         = txt_box1.Text;
                            model.dataMakeTime = dt;
                            model.dataMakeUser = AppDrill.username;
                            model.dataMakePGM  = "SelectList";
                            model.dataUpdTime  = dt;
                            model.dataUpdUser  = AppDrill.username;;
                            model.dataUpdPGM   = "SelectList";
                            db.Table_MudChemicalsAdded.Add(model);
                            db.SaveChanges();
                        }
                        break;
                    }
                }
                else
                {
                    this.selectText = this.rlv_selectItem.SelectedItem.Text;
                }
            }
            catch
            {
                this.selectText = null;
            }
        }
Esempio n. 13
0
        //保存数据操作
        private void SaveData()
        {
            int dataCount = this.dgv_rota.Rows.Count;//获取总行数

            for (int i = 0; i < dataCount; i++)
            {
                string   Name     = this.dgv_rota.Rows[i].Cells[3].Value == null ? "" : this.dgv_rota.Rows[i].Cells[3].Value.ToString();
                string   Content  = this.dgv_rota.Rows[i].Cells[4].Value == null ? "" : this.dgv_rota.Rows[i].Cells[4].Value.ToString();
                int      Shift    = ((i / list_type.Count) + 1) % SHIFT == 0 ? 2 : ((i / list_type.Count) + 1) % SHIFT;//判断早1晚2
                int      TypeWork = list_type.Where(o => o.Type == this.dgv_rota.Rows[i].Cells[2].Value.ToString()).Select(o => o.ID).FirstOrDefault();
                DateTime date     = Convert.ToDateTime(this.dgv_rota.Rows[i].Cells[0].Value);
                Rota     old      = list_rota.Where(o => o.Shift == Shift && o.TypeWork == TypeWork && Convert.ToDateTime(o.WorkTime).ToString("yyyy-MM-dd") == date.ToString("yyyy-MM-dd")).FirstOrDefault();
                //判断当前任务是否安排人员
                if (old != null)
                {
                    old.Name        = Name;
                    old.Content     = Content;
                    old.Shift       = Shift;
                    old.TypeWork    = TypeWork;
                    old.WorkTime    = date;
                    old.dataUpdPGM  = "Rota";
                    old.dataUpdTime = DateTime.Now;
                    old.dataUpdUser = AppDrill.username;
                }
                else if (!string.IsNullOrEmpty(Name))
                {
                    Rota newRota = new Rota();
                    newRota.Name         = Name;
                    newRota.Content      = Content;
                    newRota.Shift        = Shift;
                    newRota.TypeWork     = TypeWork;
                    newRota.WorkTime     = date;
                    newRota.dataMakePGM  = "Rota";
                    newRota.dataMakeTime = DateTime.Now;
                    newRota.dataMakeUser = AppDrill.username;
                    newRota.dataUpdPGM   = "Rota";
                    newRota.dataUpdTime  = DateTime.Now;
                    newRota.dataUpdUser  = AppDrill.username;
                    db.Rota.Add(newRota);
                }
                else
                {
                    continue;//结束当前循环
                }
            }
            db.SaveChanges();
        }
Esempio n. 14
0
        private void radButton5_Click(object sender, EventArgs e)
        {
            try
            {
                //查询当前的laydown的数据
                var numdata = db.DrillTools.Where(o => o.DrillId == DrillID && o.Basic == 1 && o.status == 0).ToList();
                if (numdata.Count != 0)
                {
                    //获取选中的项的group值,转化为int形的
                    int num = (int)Decimal.Parse(gvw_laydown.Rows[gvw_laydown.CurrentRow.Index].Cells[2].Value.ToString());
                    //linq的模糊查询,查出这三条数据,然后放到下一个gridview里面去
                    var query = db.DrillTools.Where(o => (int)o.Group == num && o.status == 0 && o.DrillId == DrillID).ToList();

                    //修改两个界面的内容
                    DrillTools d    = new DrillTools();
                    var        data = db.DrillTools.Where(o => o.status == 1 && o.DrillId == DrillID).ToList();
                    //linq的模糊查询,查出这三条数据,然后放到下一个gridview里面去
                    for (int i = 0; i < 3; i++)
                    {
                        decimal number = (decimal)query[i].Group;
                        d        = db.DrillTools.Where(o => o.Group == number && o.status == 0 && o.DrillId == DrillID).FirstOrDefault();
                        d.status = 1;
                        d.Group  = data.Count / 3 + 1 + i % 3 * 0.1M;
                        //修改为当前的时间
                        d.Date = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        db.SaveChanges();
                    }
                    //刷新页面
                    setGridViewdata(0);
                    ToolManageForm_Load(sender, e);
                }
            }
            catch { }
        }
Esempio n. 15
0
        private void OK_Click(object sender, EventArgs e)
        {
            bool reset = false;//定义是否重新启动页面

            #region 语言设置
            try
            {
                RadListDataItem selectLanguage = (RadListDataItem)rdp_language.SelectedItem.Value;
                if (selectLanguage.Value.ToString() != AppDrill.language)
                {
                    SetValue("Language", selectLanguage.Value.ToString());
                    AppDrill.language = selectLanguage.Value.ToString();
                    reset             = true;
                }
            }
            catch
            { }
            #endregion

            #region  择切换井
            RadListDataItem selectedItem = (RadListDataItem)rdp_wellNo.SelectedItem.Value;//必须取value然后转换再获取value
            var             DrillId      = -1;
            if (int.TryParse(selectedItem.Value.ToString(), out DrillId))
            {
                try
                {
                    if (DrillId != -1 && DrillId != AppDrill.DrillID)
                    {
                        SetValue("DrillID", DrillId.ToString());
                        AppDrill.DrillID = DrillId;
                        CurrentDrill c = _db.CurrentDrill.FirstOrDefault();
                        if (c != null && AppDrill.permissionId == 1)
                        {
                            c.CurrentDirllId = DrillId;//修改当前井号
                        }
                        //切换井之后进行自动导入测点操作
                        List <DrillTag> tag_list = _db.DrillTag.Where(o => o.DrillId == DrillId).ToList();
                        //如果查询到换井之后没数据,那么自动导入1号井的测点数据
                        if (tag_list.Count == 0)
                        {
                            _db.Database.ExecuteSqlCommand(@"insert into DrillTag SELECT [DrillId]={0}
                                                                                              ,[Tag]
                                                                                              ,[DefaultFrom]
                                                                                              ,[DefaultTo]
                                                                                              ,[Unit]
                                                                                              ,[HValue]
                                                                                              ,[LValue]
                                                                                              ,[Type]
                                                                                              ,[AlarmFlag]
                                                                                              ,[IsBool]
                                                                                              ,[dataMakeTime]={1}
                                                                                              ,[dataMakeUser]={2}
                                                                                              ,[dataMakePGM]={3}
                                                                                              ,[dataUpdTime]={4}
                                                                                              ,[dataUpdUser]={5}
                                                                                              ,[dataUpdPGM]={6}
                                                                                          FROM [DrillOS].[dbo].[DrillTag] where DrillId=1", new object[] { DrillId, DateTime.Now, AppDrill.username, "AddTag", DateTime.Now, AppDrill.username, "AddTag" });
                        }
                        _db.SaveChanges();
                        reset = true;
                    }
                }
                catch { }
            }
            #endregion

            #region 公英制选择
            try
            {
                RadListDataItem selectedType = (RadListDataItem)rdp_sys.SelectedItem.Value;//必须取value然后转换再获取value
                if (selectedType.Value.ToString() != "-1" && selectedType.Value.ToString() != AppDrill.UnitFormat)
                {
                    RadListDataItem selectSys = (RadListDataItem)rdp_sys.SelectedItem.Value;
                    SetValue("System", selectSys.Value.ToString());
                    AppDrill.UnitFormat = selectedType.Value.ToString();
                    reset = true;
                }
            }
            catch { }
            #endregion
            #region 界面设置启用
            try
            {
                string formSet = "";
                if (check_dir.Checked)
                {
                    formSet += "DirectionalForm";
                }
                if (check_gas.Checked)
                {
                    if (string.IsNullOrEmpty(formSet))
                    {
                        formSet += "DrillingGasForm";
                    }
                    else
                    {
                        formSet += ",DrillingGasForm";
                    }
                }
                if (check_tool.Checked)
                {
                    if (string.IsNullOrEmpty(formSet))
                    {
                        formSet += "ToolManageForm";
                    }
                    else
                    {
                        formSet += ",ToolManageForm";
                    }
                }
                if (check_rota.Checked)
                {
                    if (string.IsNullOrEmpty(formSet))
                    {
                        formSet += "RotaForm";
                    }
                    else
                    {
                        formSet += ",RotaForm";
                    }
                }
                string old_formSet = "";
                for (int i = 0; i < AppDrill.FormSet.Length; i++)
                {
                    if (i == 0)
                    {
                        old_formSet += AppDrill.FormSet[i];
                    }
                    else
                    {
                        old_formSet += "," + AppDrill.FormSet[i];
                    }
                }
                if (formSet != old_formSet)
                {
                    SetValue("FormSet", formSet);
                    AppDrill.FormSet = formSet.Split(',');
                    reset            = true;
                }
            }
            catch { }
            #endregion
            this.Close();
            //判断是否应该进行重启
            if (reset)
            {
                List <Form> disForm = new List <Form>();
                int         num     = Application.OpenForms.Count;
                for (int i = 0; i < num; i++)
                {
                    Form f = Application.OpenForms[i];
                    if (f.Name != "LoginForm")
                    {
                        disForm.Add(f);
                    }
                }
                foreach (var item in disForm)
                {
                    item.Dispose();
                }
                AppDrill.message.Clear();
                AppDrill.Command.Clear();
                //开启全部带有数据显示的界面
                DrillForm main = new DrillForm();
                main.Size = new System.Drawing.Size(1920, 1080);
                main.Show();
                //CirculateForm circulate = new CirculateForm();
                //circulate.WindowState = FormWindowState.Minimized;
                //circulate.Show();
                //DrillPVTForm pvt = new DrillPVTForm();
                //pvt.WindowState = FormWindowState.Minimized;
                //pvt.Show();
                //if (AppDrill.FormSet.Contains("DrillingGasForm"))
                //{
                //    DrillingGasForm gas = new DrillingGasForm();
                //    gas.WindowState = FormWindowState.Minimized;
                //    gas.Show();
                //}
                //if (AppDrill.FormSet.Contains("DirectionalForm"))
                //{
                //    DirectionalForm direction = new DirectionalForm();
                //    direction.WindowState = FormWindowState.Minimized;
                //    direction.Show();
                //}
            }
        }
Esempio n. 16
0
 private void modifyUserInfo(User user, int ilogTimestamp)
 {
     user.isActive  = true;
     user.timeStamp = ilogTimestamp;
     _db.SaveChanges();
 }
Esempio n. 17
0
        private void save_Click(object sender, EventArgs e)
        {
            this.lbl_Status.Text = "";
            TagModel             = new TagSimpleModel();
            TagModel.HValue      = string.IsNullOrEmpty(txt_HighAlarm.Text) ? 99999 : decimal.Parse(txt_HighAlarm.Text);
            TagModel.LValue      = string.IsNullOrEmpty(txt_LowAlarm.Text) ? -99999 : decimal.Parse(txt_LowAlarm.Text);

            if (TagModel.LValue >= TagModel.HValue)
            {
                this.lbl_Status.ForeColor = Color.Red;
                this.lbl_Status.Text      = list_status[3];
                return;
            }

            //string Tag = list_tagdir.Where(o => o.TagShowName == lbl_TagId.Text).Select(o => o.Basic).FirstOrDefault();
            TagModel.Tag     = string.IsNullOrEmpty(lbl_TagId.Text) ? "" : lbl_TagId.Text;
            TagModel.DrillId = string.IsNullOrEmpty(lbl_DrillId.Text) ? 0 : int.Parse(lbl_DrillId.Text);
            btn_Save.Enabled = false;
            btn_Save.Text    = "Wait...";

            try
            {
                //if (AppDrill.username == "admin")
                //{
                //    backgroundWorker2.RunWorkerAsync(); //开始
                //}

                ////0711修改,将上下限报警是否启用保存到drilltag
                //_db.DrillTag.Where(o => o.DrillId == 1 && o.Tag == TagModel.Tag).FirstOrDefault().HisActive = chb_H.Checked;
                //_db.DrillTag.Where(o => o.DrillId == 1 && o.Tag == TagModel.Tag).FirstOrDefault().LisActive = chb_L.Checked;
                //0710保存到 jsonalarm
                //JsonAlarm model = new JsonAlarm();
                //model.H = string.IsNullOrEmpty(txt_HighAlarm.Text) ? 99999 : double.Parse(txt_HighAlarm.Text);
                //model.L = string.IsNullOrEmpty(txt_LowAlarm.Text) ? -99999 : double.Parse(txt_LowAlarm.Text);
                //model.HIsActive = chb_H.Checked;
                //model.LIsActive = chb_L.Checked;
                //model.Tag = AlarmtagList[lst_channel.SelectedIndex].Tag;

                //0714批量修改
                //因为templist只会在切换的时候添加,所以最后一条记录要先修改到templist
                if (TempAlarmList.ContainsKey(lst_channel.SelectedIndex))
                {
                    TempAlarmList[lst_channel.SelectedIndex].H         = string.IsNullOrEmpty(txt_HighAlarm.Text) ? 99999 : double.Parse(txt_HighAlarm.Text);
                    TempAlarmList[lst_channel.SelectedIndex].L         = string.IsNullOrEmpty(txt_LowAlarm.Text) ? -99999 : double.Parse(txt_LowAlarm.Text);
                    TempAlarmList[lst_channel.SelectedIndex].HIsActive = chb_H.Checked;
                    TempAlarmList[lst_channel.SelectedIndex].LIsActive = chb_L.Checked;
                    TempAlarmList[lst_channel.SelectedIndex].Tag       = AlarmtagList[current_index].Tag;
                }
                else
                {
                    JsonAlarm tag = new JsonAlarm();
                    tag.H         = string.IsNullOrEmpty(txt_HighAlarm.Text) ? 99999 : double.Parse(txt_HighAlarm.Text);
                    tag.L         = string.IsNullOrEmpty(txt_LowAlarm.Text) ? -99999 : double.Parse(txt_LowAlarm.Text);
                    tag.HIsActive = chb_H.Checked;
                    tag.LIsActive = chb_L.Checked;
                    tag.Tag       = AlarmtagList[current_index].Tag;
                    TempAlarmList.Add(current_index, tag);
                }

                if (TempAlarmList.Count != 0)
                {
                    foreach (JsonAlarm item in TempAlarmList.Values)
                    {
                        var data = JsonAlarmList.Where(o => o.Tag == item.Tag).FirstOrDefault();

                        if (data == null)
                        {
                            //  JsonAlarm model = new JsonAlarm();
                            //   setJsonAlarm(model);
                            JsonAlarmList.Add(item);
                        }
                        else
                        {
                            setJsonAlarm(data, item);
                        }
                    }
                }
                //0716修改,如果是管理员权限会修改报警测点的上下限,影响统计结果,取消http请求的方式
                if (AppDrill.username == "admin")
                {
                    if (TempAlarmList.Count != 0)
                    {
                        foreach (JsonAlarm item in TempAlarmList.Values)
                        {
                            var data = _db.DrillTag.Where(o => o.DrillId == 1 && o.Tag == item.Tag).FirstOrDefault();
                            if (data != null)
                            {
                                data.HisActive = item.HIsActive;
                                data.LisActive = item.LIsActive;
                                data.HValue    = (decimal)item.H;
                                data.LValue    = (decimal)item.L;
                            }
                        }
                    }
                }


                AppDrill.JsonAlarmList = JsonAlarmList;
                string json = new JavaScriptSerializer().Serialize(JsonAlarmList);
                _db.UserTagRef.Where(o => o.Username == AppDrill.username).FirstOrDefault().JsonAlarm = json;
                _db.SaveChanges();

                this.lbl_Status.ForeColor = Color.Lime;
                this.lbl_Status.Text      = list_status[0];
                btn_Save.Enabled          = true;
                btn_Save.Text             = save;
            }
            catch (Exception)
            {
                this.lbl_Status.ForeColor = Color.Red;
                this.lbl_Status.Text      = list_status[1];
                //    MessageBox.Show(AppDrill.message[5]);//请勿重复点击
            }
        }
Esempio n. 18
0
        private void radButton1_Click(object sender, EventArgs e)
        {
            try
            {
                using (var dbContext = new DrillOSEntities())
                {
                    //是否存在被选中后的Tag
                    var data = dbContext.ActivityStatus.Where(o => o.IsSelect == true && o.DrillID == AppDrill.DrillID).FirstOrDefault();
                    //置为红色背景的按钮
                    var SelectBtn = btnList.Where(o => o.BackColor == Color.Red).FirstOrDefault();

                    //如果用户取消了选中
                    if (SelectBtn == null)
                    {
                        if (data == null)
                        {
                            this.Close();
                            return;
                        }
                        data.IsSelect     = false;
                        data.SelectDateTo = DateTime.Now;

                        data.dataUpdPGM  = "DrillingSystemCSCV2";
                        data.dataUpdTime = DateTime.Now;
                        data.dataUpdUser = AppDrill.username;

                        dbContext.SaveChanges();
                        bsform.setActivityTitle(defaultString);
                        OldSelectName = "";
                        this.Close();
                        return;
                    }

                    //重复选中无意义
                    if (OldSelectName == SelectBtn.Text)
                    {
                        this.Close();
                        return;
                    }

                    if (data == null)
                    {
                        //不存在被占用的按钮
                        //insert data
                        var insertData = new ActivityStatus();

                        var strM = "";
                        var M    = LanuangeDictionary.Where(o => o.Value == SelectBtn.Text).Select(o => o.Key).FirstOrDefault(); //get all keys
                        if (M != null)
                        {
                            strM = M + "_" + SelectBtn.Text;
                        }

                        insertData.ActivityName   = strM;
                        insertData.DrillID        = AppDrill.DrillID;
                        insertData.SelectDateForm = DateTime.Now;
                        insertData.IsSelect       = true;

                        insertData.dataMakeTime = DateTime.Now;
                        insertData.dataMakeUser = AppDrill.username;
                        insertData.dataMakePGM  = "DrillingSystemCSCV2";

                        dbContext.ActivityStatus.Add(insertData);
                        dbContext.SaveChanges();
                    }
                    else
                    {
                        //存在被占用的按钮
                        if (data.SelectDateTo != null)
                        {
                            //如果没有SelectToTime
                            //update data

                            //把之前的东西选中项为 false
                            data.IsSelect    = false;
                            data.dataUpdPGM  = "DrillingSystemCSCV2";
                            data.dataUpdTime = DateTime.Now;
                            data.dataUpdUser = AppDrill.username;

                            //插入新的数据 并设置选中为true
                            var insertData = new ActivityStatus();


                            var strM = "";
                            var M    = LanuangeDictionary.Where(o => o.Value == SelectBtn.Text).Select(o => o.Key).FirstOrDefault(); //get all keys
                            if (M != null)
                            {
                                strM = M + "_" + SelectBtn.Text;
                            }

                            insertData.ActivityName   = strM;
                            insertData.DrillID        = AppDrill.DrillID;
                            insertData.SelectDateForm = DateTime.Now;
                            insertData.IsSelect       = true;

                            insertData.dataMakeTime = DateTime.Now;
                            insertData.dataMakeUser = AppDrill.username;
                            insertData.dataMakePGM  = "DrillingSystemCSCV2";

                            dbContext.ActivityStatus.Add(insertData);

                            dbContext.SaveChanges();
                        }
                        else
                        {
                            //如果有SelectToTime
                            //insert data
                            data.IsSelect     = false;
                            data.SelectDateTo = DateTime.Now;
                            data.dataUpdPGM   = "DrillingSystemCSCV2";
                            data.dataUpdTime  = DateTime.Now;
                            data.dataUpdUser  = AppDrill.username;

                            var insertData = new ActivityStatus();


                            var strM = "";
                            var M    = LanuangeDictionary.Where(o => o.Value == SelectBtn.Text).Select(o => o.Key).FirstOrDefault(); //get all keys
                            if (M != null)
                            {
                                strM = M + "_" + SelectBtn.Text;
                            }

                            insertData.ActivityName   = strM;
                            insertData.DrillID        = AppDrill.DrillID;
                            insertData.SelectDateForm = DateTime.Now;
                            insertData.IsSelect       = true;

                            insertData.dataMakeTime = DateTime.Now;
                            insertData.dataMakeUser = AppDrill.username;
                            insertData.dataMakePGM  = "DrillingSystemCSCV2";

                            dbContext.ActivityStatus.Add(insertData);
                            dbContext.SaveChanges();
                        }
                    }

                    if (SelectBtn == null)
                    {
                        bsform.setActivityTitle(defaultString);
                    }
                    else
                    {
                        bsform.setActivityTitle(SelectBtn.Text);
                    }
                    OldSelectName = SelectBtn.Text;
                }
            }
            catch {
            }

            try
            {
                this.Close();
            }
            catch { }
        }
Esempio n. 19
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            string drillNo;

            if (string.IsNullOrEmpty(rtxt_drillNo.Text.Trim()))
            {
                isCancle = true;
                MessageBox.Show(list_error[0]);
                return;
            }
            drillNo = rtxt_drillNo.Text.Trim();
            try
            {
                Drill drill = list_drill.Where(o => o.DrillNo == drillNo).FirstOrDefault();
                if (drill == null)
                {
                    DialogResult dr = MessageBox.Show(list_error[1], "", MessageBoxButtons.OKCancel);
                    if (dr == DialogResult.Cancel)
                    {
                        isCancle = true;
                        return;//如果取消,直接return
                    }
                    Drill d = new Drill();
                    d.DrillNo      = rtxt_drillNo.Text;
                    d.Lease        = rtxt_lease.Text;
                    d.Company      = rtxt_company.Text;
                    d.CompanyMan   = rtxt_cm.Text;
                    d.Contractor   = rtxt_contractor.Text;
                    d.DateRelease  = rtxt_dr.Text;
                    d.DateSpud     = rtxt_ds.Text;
                    d.ToolPusher   = rtxt_tp.Text;
                    d.Country      = rtxt_country.Text;
                    d.dataMakePGM  = "AddWell";
                    d.dataMakeTime = DateTime.Now;
                    d.dataMakeUser = AppDrill.username;
                    d.dataUpdPGM   = "AddWell";
                    d.dataUpdTime  = DateTime.Now;
                    d.dataUpdUser  = AppDrill.username;
                    db.Drill.Add(d);
                    db.SaveChanges();
                }
                else
                {
                    DialogResult dr = MessageBox.Show(list_error[2], "", MessageBoxButtons.OKCancel);
                    if (dr == DialogResult.Cancel)
                    {
                        isCancle = true;
                        return;//如果取消,直接return
                    }
                    drill.Lease       = rtxt_lease.Text;
                    drill.Company     = rtxt_company.Text;
                    drill.CompanyMan  = rtxt_cm.Text;
                    drill.Contractor  = rtxt_contractor.Text;
                    drill.DateRelease = rtxt_dr.Text;
                    drill.DateSpud    = rtxt_ds.Text;
                    drill.ToolPusher  = rtxt_tp.Text;
                    drill.Country     = rtxt_country.Text;
                    drill.dataUpdPGM  = "AddWell";
                    drill.dataUpdTime = DateTime.Now;
                    drill.dataUpdUser = AppDrill.username;
                    db.SaveChanges();
                }
                MessageBox.Show(AppDrill.message[3]);//保存成功
            }
            catch
            {
                MessageBox.Show(AppDrill.message[4]);//保存失败
            }
        }
Esempio n. 20
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            //首先输入信息不能为空
            foreach (Control ctr in panel1.Controls)
            {
                if (ctr is TextBox)
                {
                    TextBox txb = ctr as TextBox;
                    if (string.IsNullOrEmpty(txb.Text))
                    {
                        lbl_warm.Visible = true;
                        return;
                    }
                }
            }
            //如果新建一口井
            if (isNew)
            {
                DialogResult result = MessageBox.Show("警告!,新建井后原有井口数据接口将关闭,单击确定按钮继续!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.OK)
                {
                    using (db = new Model.DrillOSEntities())
                    {
                        Drill item = new Model.Drill();
                        item.DateSpud     = dateTimePicker1.Value.ToString();
                        item.design_depth = txb_depth.Text;
                        item.DrillNo      = txb_drillNo.Text;
                        item.latitude     = float.Parse(txb_lati.Text);
                        item.Lease        = txb_location.Text;
                        item.longitude    = float.Parse(txb_longi.Text);
                        item.Operator     = txb_operator.Text;
                        item.period       = txb_period.Text;
                        item.RigNo        = txb_rigNo.Text;

                        //重要信息
                        var olditem = db.Drill.Where(o => o.Contractor == contractor && o.isActive == true).FirstOrDefault();
                        olditem.isActive = false;
                        item.Contractor  = lbl_contractor.Text;
                        item.isActive    = true;
                        db.Drill.Add(item);
                        db.SaveChanges();
                    }
                }
            }
            //更新信息
            else
            {
                using (db = new Model.DrillOSEntities())
                {
                    var item = db.Drill.Where(o => o.Contractor == contractor && o.isActive == true).FirstOrDefault();
                    item.DateSpud     = dateTimePicker1.Value.ToString();
                    item.design_depth = txb_depth.Text;
                    item.DrillNo      = txb_drillNo.Text;
                    item.latitude     = float.Parse(txb_lati.Text);
                    item.Lease        = txb_location.Text;
                    item.longitude    = float.Parse(txb_longi.Text);
                    item.Operator     = txb_operator.Text;
                    item.period       = txb_period.Text;
                    item.RigNo        = txb_rigNo.Text;
                    db.SaveChanges();
                }
            }
            lbl_warm.Visible = false;
            this.Close();
        }