示例#1
0
        /// <summary>
        /// 数据操作
        /// </summary>
        /// <param name="Mess">区别编辑还是新增还是删除</param>
        private void OpreationDB(string Mess)
        {
            BaseDataClass.PersonnelInfoList PersonList = new PersonnelInfoList();
            PersonList.PersonName        = this.tbx_Name.Text.ToString();
            PersonList.PersonID          = this.tbx_ID.Text.ToString();
            PersonList.PersonNation      = this.tbx_Nation.Text.ToString();
            PersonList.Post              = this.tbx_post.Text.ToString();
            PersonList.Unit              = this.tbx_Unit.Text.ToString();
            PersonList.ContactInfo       = this.tbx_contactinfo.Text.ToString();
            PersonList.DateOfBirth       = this.TimePicker_DateOfBirth.Value.ToString("yyyy-MM-dd");
            PersonList.DegreeOfEducation = this.tbx_DegreeOfEducation.Text.ToString();
            PersonList.EnlistmentTime    = this.TimePicker_Intime.Value.ToString("yyyy-MM-dd");
            PersonList.RetiredTime       = this.TimePicker_Outtime.Value.ToString("yyyy-MM-dd");
            PersonList.NativePlace       = this.tbx_place.Text.ToString();
            PersonList.Description       = this.tbx_descrip.Text.ToString();

            deviceInfo PersonInfo = new deviceInfo();
            string     Error      = "";
            bool       Result     = false;

            if (Mess == "添加")
            {
                if (tbx_ID.Text.Trim() != "")
                {
                    deviceInfo device = new deviceInfo();
                    //string sql = "select * from PersonnelListInfo where PersonID =‘" + tbx_ID.Text.Trim()+"’";
                    //DataSet result= device.gettablebycondition(sql);
                    log_tabel log = new log_tabel();
                    log.addrow("PersonID", tbx_ID.Text.Trim(), log_tabel.operatetype.equal, log_tabel.mark.normal);
                    int i = device.GetRecordCount(logs.PersonnelInfoList, log);
                    if (i > 0)
                    {
                        MessageBox.Show("用户编号重复 请重新录入!");
                    }
                    else
                    {
                        Result = PersonInfo.AddBaseList(PersonList, ref Error);
                    }
                }
            }
            if (Mess == "编辑")
            {
                Result = PersonInfo.UpdateBaselist(PersonList, ref Error);
            }
            if (Mess == "删除")
            {
                Result = PersonInfo.DeleteOneRecord(BaseDataClassNames.PersonnelInfoList, PersonList.PersonID, ref Error);
            }
            if (Result == true)
            {
                MessageBox.Show("人员信息" + Mess + "成功");
                ClearText(this.Content);
            }
            else
            {
                MessageBox.Show("人员信息" + Mess + "失败,请稍后再试!");
                ClearText(this.Content);
            }
        }
示例#2
0
        /// <summary>
        /// 数据操作
        /// </summary>
        /// <param name="Mess">区别编辑还是新增还是删除</param>
        private void OpreationDB(string Mess)
        {
            BaseDataClass.EquipmentInfoList Equiplist = new EquipmentInfoList();

            Equiplist.EquipmentID    = this.tbx_ID.Text.Trim();
            Equiplist.EquipmentName  = this.tbx_Name.Text.Trim();
            Equiplist.EquipmentModel = this.tbx_EquipNum.Text.Trim();
            Equiplist.EquipmentType  = this.tbx_EquipType.Text.Trim();
            Equiplist.PersonIncharge = this.tbx_PersonIncharge.Text.Trim();
            Equiplist.ReturnDate     = this.TimePicker_ReturnDate.Value.ToString("yyyy-MM-dd");
            Equiplist.AllottedDate   = this.TimePicker_Intime.Value.ToString("yyyy-MM-dd");
            Equiplist.Description    = this.tbx_descrip.Text;
            Equiplist.Unit           = this.tbx_Unit.Text;
            Equiplist.EquipmentState = this.tbx_EquipmentState.Text;
            deviceInfo PersonInfo = new deviceInfo();
            string     Error      = "";
            bool       Result     = false;

            if (Mess == "添加")
            {
                if (tbx_ID.Text.Trim() != "")
                {
                    //deviceInfo device = new deviceInfo();
                    //string sql = "select * from EquipmentInfoList where EquipmentID =" + tbx_ID.Text.Trim();
                    //DataSet result= device.gettablebycondition(sql);
                    deviceInfo device = new deviceInfo();
                    log_tabel  log    = new log_tabel();
                    log.addrow("EquipmentID", tbx_ID.Text.Trim(), log_tabel.operatetype.equal, log_tabel.mark.normal);
                    int i = device.GetRecordCount(logs.EquipmentInfoList, log);
                    if (i > 0)
                    {
                        MessageBox.Show("设备编号重复 请重新录入!");
                    }
                    else
                    {
                        Result = PersonInfo.AddBaseList(Equiplist, ref Error);
                    }
                }
            }
            if (Mess == "编辑")
            {
                Result = PersonInfo.UpdateBaselist(Equiplist, ref Error);
            }
            if (Mess == "删除")
            {
                Result = PersonInfo.DeleteOneRecord(BaseDataClassNames.EquipmentInfoList, Equiplist.EquipmentID, ref Error);
            }
            if (Result == true)
            {
                MessageBox.Show("设备信息" + Mess + "成功");
                ClearText(this.Content);
            }
            else
            {
                MessageBox.Show("设备信息" + Mess + "失败,请稍后再试!");
                ClearText(this.Content);
            }
        }
示例#3
0
        /// <summary>
        /// 数据操作
        /// </summary>
        /// <param name="Mess">区别编辑还是新增还是删除</param>
        private void OpreationDB(string Mess)
        {
            BaseDataClass.DutyRecordInfoList DutyLIst = new DutyRecordInfoList();

            DutyLIst.DutyPerson = tbx_Name.Text.Trim();
            DutyLIst.PersonID   = tbx_ID.Text.Trim();
            DutyLIst.DutyDate   = TimePicker_DutyDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
            DutyLIst.DutyEvent  = tbx_DutyEvent.Text;
            if (tbx_DutyEvent.Text == "")
            {
                DutyLIst.DutyEventTime = "";
            }
            DutyLIst.DutyEventTime = TimePicker_DutyEventTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
            DutyLIst.DutyRoute     = tbx_DutyRoute.Text;
            DutyLIst.Description   = tbx_descrip.Text;
            DutyLIst.Mark          = cbx_Plan.SelectedText;//预留字段MARK这里用来保存预案处置结果


            deviceInfo PersonInfo = new deviceInfo();
            string     Error      = "";
            bool       Result     = false;

            if (Mess == "添加")
            {
                Result = PersonInfo.AddBaseList(DutyLIst, ref Error);
            }
            if (Mess == "编辑")
            {
                DutyLIst.ID = Convert.ToInt32(infoList[0].ToString());
                Result      = PersonInfo.UpdateBaselist(DutyLIst, ref Error);
            }
            if (Mess == "删除")
            {
                DutyLIst.ID = Convert.ToInt32(infoList[0].ToString());
                Result      = PersonInfo.DeleteOneRecord(BaseDataClassNames.DutyRecordInfoList, DutyLIst.ID, ref Error);
            }
            if (Result == true)
            {
                MessageBox.Show("设备信息" + Mess + "成功");
                ClearText(this.Content);
                this.Close();
            }
            else
            {
                MessageBox.Show("设备信息" + Mess + "失败,请稍后再试!");
                ClearText(this.Content);
            }
        }
示例#4
0
 /// <summary>
 /// 数据操作
 /// </summary>
 /// <param name="Mess">区别编辑还是新增还是删除</param>
 private void OpreationDB(string Mess)
 {
     BaseDataClass.PlanManagementInfoList Planlist = new PlanManagementInfoList();
     try
     {
         Planlist.PlanContent = this.tbx_PlanContent.Text;
         Planlist.PlanID      = this.tbx_PlanID.Text.Trim();
         deviceInfo PersonInfo = new deviceInfo();
         string     Error      = "";
         bool       Result     = false;
         if (Mess == "添加")
         {
             if (CheckIDIsrepeat())
             {
                 Result = PersonInfo.AddBaseList(Planlist, ref Error);
             }
         }
         if (Mess == "编辑")
         {
             Result = PersonInfo.UpdateBaselist(Planlist, ref Error);
         }
         if (Mess == "删除")
         {
             Result = PersonInfo.DeleteOneRecord(BaseDataClassNames.PlanManagementInfoList, Planlist.PlanID, ref Error);
         }
         if (Result == true)
         {
             MessageBox.Show("预案信息" + Mess + "成功");
             ClearText(this.Content);
         }
         else
         {
             MessageBox.Show("预案信息" + Mess + "失败,请稍后再试!");
             ClearText(this.Content);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#5
0
        private void btnsure_Click(object sender, EventArgs e)
        {
            double lon = 0.0, lat = 0.0, alt = 0.0;

            if (txtlon.Text.Trim() == "")
            {
                MessageBox.Show("请填写经度");
                return;
            }
            else
            {
                if (!double.TryParse(txtlon.Text.Trim(), out lon))
                {
                    MessageBox.Show("经度为数值类型");
                    return;
                }
            }
            if (txtlat.Text.Trim() == "")
            {
                MessageBox.Show("请填写纬度");
                return;
            }
            else
            {
                if (!double.TryParse(txtlat.Text.Trim(), out lat))
                {
                    MessageBox.Show("纬度为数值类型");
                    return;
                }
            }
            if (txtalt.Text.Trim() == "")
            {
                MessageBox.Show("请填写海拔");
                return;
            }
            else
            {
                if (!double.TryParse(txtalt.Text.Trim(), out alt))
                {
                    MessageBox.Show("海拔为数值类型");
                    return;
                }
            }
            if (comboBoxSerialCOM.Text.Trim() == "" || comboBoxSerialCOM.Text.Trim() == "(无)")
            {
                UPS_Obj.UPSBase.COM = "";
            }
            else
            {
                if (DictionaryDBClass.SerialCOMListDictionary.ContainsKey(comboBoxSerialCOM.SelectedValue.ToString()))
                {
                    UPS_Obj.SerialCOM_assembly = DictionaryDBClass.SerialCOMListDictionary[comboBoxSerialCOM.SelectedValue.ToString()];
                    UPS_Obj.UPSBase.COM        = UPS_Obj.SerialCOM_assembly.SerialCOMBase.DeviceID;
                }
                else
                {
                    MessageBox.Show("选择的串口不存在");
                    return;
                }
            }
            if (txtname.Text.Trim() == "")
            {
                MessageBox.Show("请填写名称");
                return;
            }
            if (txtname.Text.Trim() != "")
            {
                if (Operate_Type.Contains("添加"))
                {
                    foreach (assembly_UPS name in DictionaryDBClass.UPSDictionary.Values)
                    {
                        if (txtname.Text.Trim() == name.UPSBase.Name)
                        {
                            MessageBox.Show("此UPS名称已存在,请修改后重试!");
                            return;
                        }
                    }
                }
                else
                {
                    foreach (assembly_UPS name in DictionaryDBClass.UPSDictionary.Values)
                    {
                        if (txtname.Text.Trim() == name.UPSBase.Name && txtname.Text.Trim() != UPS_Obj.UPSBase.Name)
                        {
                            MessageBox.Show("此UPS名称已存在,请修改后重试!");
                            return;
                        }
                    }
                }
            }
            if (txtusername.Text.Trim() == "")
            {
                MessageBox.Show("请填写用户名");
                return;
            }
            string[] ipstring = txtip.Text.Trim().Split('.');
            if (ipstring.Length == 0)
            {
                MessageBox.Show("请填写IP");
                return;
            }
            else
            {
                if (ipstring.Length == 4)
                {
                    int string_to_int = 0;
                    for (int i = 0; i < ipstring.Length; i++)
                    {
                        if (!int.TryParse(ipstring[i], out string_to_int))
                        {
                            MessageBox.Show("IP格式不合法");
                            return;
                        }
                        if (string_to_int > 254 || string_to_int < 0 || string_to_int.ToString() != ipstring[i])
                        {
                            MessageBox.Show("IP格式不合法");
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("IP格式不合法");
                    return;
                }
            }

            if (txtport.Text.Trim() == "")
            {
                MessageBox.Show("请填写端口");
                return;
            }
            else
            {
                int port = 0;
                if (!int.TryParse(txtport.Text.Trim(), out port))
                {
                    MessageBox.Show("端口号要为数字");
                    return;
                }
            }

            if (comboBoxCommunicationInternet.SelectedValue.ToString() != "")
            {
                UPS_Obj.CommunicationAssembly           = DictionaryDBClass.communicationInternetDictionary[comboBoxCommunicationInternet.SelectedValue.ToString()];
                UPS_Obj.UPSBase.CommunicationInternetID = comboBoxCommunicationInternet.SelectedValue.ToString();
            }
            else
            {
                UPS_Obj.CommunicationAssembly           = new assembly_communicationInternet();
                UPS_Obj.UPSBase.CommunicationInternetID = "";
            }
            bool operateresult = false;

            UPS_Obj.UPSBase.Name        = txtname.Text.Trim();
            UPS_Obj.UPSBase.UserName    = txtusername.Text.Trim();
            UPS_Obj.UPSBase.Password    = txtpassword.Text.Trim();
            UPS_Obj.UPSBase.Ip          = txtip.Text.Trim();
            UPS_Obj.UPSBase.Port        = txtport.Text.Trim();
            UPS_Obj.UPSBase.Lon         = txtlon.Text.Trim();
            UPS_Obj.UPSBase.Lat         = txtlat.Text.Trim();
            UPS_Obj.UPSBase.Alt         = txtalt.Text.Trim();
            UPS_Obj.UPSBase.Description = txtdescription.Text.Trim();
            string opresult = "";

            try
            {
                if (Operate_Type.Contains("添加"))
                {
                    object[] obj_list = deviceInfo_Obj.GetAllObjects(BaseDataClassNames.UPSList);
                    int      id       = 18001;
                    if (obj_list != null)
                    {
                        int[] id_list = new int[obj_list.Length];
                        for (int i = 0; i < obj_list.Length; i++)
                        {
                            id_list[i] = Convert.ToInt32((obj_list[i] as UPSList).DeviceID);
                        }
                        CountIDClass CountIDClass_Obj = new CountIDClass();
                        id = CountIDClass_Obj.CountID(id_list, 18001, 19000);
                    }
                    if (id == -1)
                    {
                        MessageBox.Show("DeviceID字段已用完");
                    }
                    else
                    {
                        UPS_Obj.UPSBase.DeviceID = id.ToString();
                        operateresult            = deviceInfo_Obj.AddBaseList(UPS_Obj.UPSBase, ref error);
                        DictionaryDBClass.UPSDictionary.Add(UPS_Obj.UPSBase.DeviceID, UPS_Obj);
                        opresult = CompletenessCheck.CheckUPSComplete(UPS_Obj);
                        DictionaryDBClass.UPSDictionary_State.Add(UPS_Obj.UPSBase.DeviceID, opresult);
                    }
                }
                else
                {
                    operateresult = deviceInfo_Obj.UpdateBaselist(UPS_Obj.UPSBase, ref error);
                    DictionaryDBClass.UPSDictionary[UPS_Obj.UPSBase.DeviceID] = UPS_Obj;
                    opresult = CompletenessCheck.CheckUPSComplete(UPS_Obj);
                    DictionaryDBClass.UPSDictionary_State[UPS_Obj.UPSBase.DeviceID] = opresult;
                }
                string Useroperation = txtname.Text.Trim();

                if (Operate_Type.Contains("添加"))
                {
                    Useroperation = "添加元素实例-" + Useroperation;
                    MessageBox.Show("添加成功");
                    UpdateTree.AddUPS(UPS_Obj, opresult);
                }
                else
                {
                    Useroperation = "修改元素实例-" + Useroperation;
                    MessageBox.Show("修改成功");
                    UpdateTree.EditUPS(UPS_Obj, opresult);
                }
                this.Close();
            }
            catch (System.Exception ex)
            {
            }
        }