Exemplo n.º 1
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            try

            {
                if (this.txtHangYeName.Text.Trim() == "")
                {
                    MessageBox.Show("行业名称不能为空!");
                    return;
                }

                string strSql   = String.Format("select count(*) from tbHangYe where HangYeName='{0}'", this.txtHangYeName.Text.Trim());
                string strCount = CDBConnection.ExecuteScalar(strSql);
                int    iCount   = Convert.ToInt32(strCount);
                if (iCount > 0)
                {
                    MessageBox.Show("该行业名称已存在!");
                    return;
                }

                strSql = String.Format("insert into tbHangYe(HangYeName,HangYeType) values('{0}','{1}')", this.txtHangYeName.Text.Trim(), this.txtHangYeType.Text.Trim());
                CDBConnection.ExecuteSql(strSql);

                this.m_bInserted = true;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void btnSet_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtInterval.Text.Trim() == "")
                {
                    MessageBox.Show("请填写时间间隔!");
                    return;
                }
                if (this.txtWarnLevel.Text.Trim() == "")
                {
                    MessageBox.Show("请填写报警下限!");
                    return;
                }
                double dWarn  = Convert.ToDouble(this.txtWarnLevel.Text.Trim());
                string strSql = String.Format("update tbInfo set val='{0}' where des='{1}'", dWarn.ToString(), "报警下限");
                CDBConnection.ExecuteSql(strSql);
                double dInter = Convert.ToDouble(this.txtInterval.Text);
                double iInter = Convert.ToDouble(dInter * 60);
                this.m_xDoc.DocumentElement.SelectSingleNode("./interval").InnerText = iInter.ToString();
                this.m_xDoc.Save("Info.xml");

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtUserID.Text.Trim() == "")
                {
                    MessageBox.Show("请填写用户ID");
                    return;
                }
                if (this.txtUserName.Text.Trim() == "")
                {
                    MessageBox.Show("请填写用户名!");
                    return;
                }
                if (this.txtUserPwd.Text.Trim() == "")
                {
                    MessageBox.Show("请填写用户密码!");
                    return;
                }
                if (this.txtUserPwd.Text.Trim() != this.txtPwdCer.Text.Trim())
                {
                    MessageBox.Show("密码与确认密码不同!");
                    return;
                }

                if (this.chkPower.Checked == true)
                {
                    if (this.cmbManagers.Text.Trim() == "")
                    {
                        MessageBox.Show("请选择具有相同权限的管理员,或去掉应用权限项!");
                        return;
                    }
                }
                else
                {
                    if (this.cmbManagers.Text.Trim() != "")
                    {
                        MessageBox.Show("请选中应用权限框,或清除所选的管理员!");
                        return;
                    }
                }

                if (this.m_bEdit == false)
                {
                    //添加用户
                    this.fInserUsers();
                }
                else
                {
                    //修改
                    string strSql = String.Format("delete from tbUsers where userID='{0}'", this.txtUserID.Text.Trim());
                    CDBConnection.ExecuteSql(strSql);
                    this.fInserUsers();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 4
0
        private void btnDel_Click(object sender, System.EventArgs e)
        {
            try
            {
                //MessageBox.Show("因为删除将导致系统错误,所以删除被禁用!");
                //return;

                if (this.lsvDep.SelectedItems.Count <= 0)
                {
                    MessageBox.Show("请选择要删除的管理处!");
                    return;
                }

                string strDepShortName = this.lsvDep.SelectedItems[0].Text.Trim();

                string strSql   = String.Format("select count(*) from tbWell where depName ='{0}'", strDepShortName);
                string strCount = CDBConnection.ExecuteScalar(strSql);
                if (strCount.Trim() != "0")
                {
                    MessageBox.Show("该单位下已录入监测站,请先删除其下的站点!");
                    return;
                }

                strSql = String.Format("delete from tbDep where depShortName='{0}'", strDepShortName);
                CDBConnection.ExecuteSql(strSql);

                this.paintFrm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 5
0
        private void btnDel_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.lsvCountry.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选中要删除的管理局!");
                    return;
                }

                string strCountryName = this.lsvCountry.SelectedItems[0].Text.Trim();
//
                string strSql   = String.Format("select count(*) from tbDep where countryName='{0}'", strCountryName);
                string strCount = CDBConnection.ExecuteScalar(strSql);
                if (strCount != "0")
                {
                    MessageBox.Show("该管理局以下已录入管理处,请先将其下的管理处信息删除!");
                    return;
                }

                strSql = String.Format("delete from tbCountry where countryName='{0}'", strCountryName);
                CDBConnection.ExecuteSql(strSql);

                this.paintFrm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 6
0
        private void btnDel_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.lsvTown.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选中要删除的县!");
                    return;
                }

                string strSql   = String.Format("select count(*) from tbCountry where townName='{0}'", this.lsvTown.SelectedItems[0].SubItems[0].Text.Trim());
                string strCount = CDBConnection.ExecuteScalar(strSql);
                if (strCount.Trim() != "0")
                {
                    MessageBox.Show("该县以下已录入乡镇信息不能删除!");
                    return;
                }

                string strTownName = this.lsvTown.SelectedItems[0].Text.Trim();
                strSql = String.Format("delete from tbTown where townName='{0}'", strTownName);
                CDBConnection.ExecuteSql(strSql);

                this.paintFrm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 7
0
        private bool saveData(string strWellNo, string strICNo, string strDepName)
        {
            string strSql = String.Format("delete from tbIC where icNo='{0}'", strICNo);

            CDBConnection.ExecuteSql(strSql);
            strSql = String.Format("insert into tbIC(wellNo,icNo,depName) values('{0}','{1}','{2}')", strWellNo, strICNo, strDepName);
            CDBConnection.ExecuteSql(strSql);
            return(true);
        }
Exemplo n.º 8
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            try

            {
                if (this.txtDepShortName.Text.Trim() == "")
                {
                    MessageBox.Show("管理处简称不能为空!");
                    return;
                }
                if (this.txtDepName.Text.Trim() == "")
                {
                    MessageBox.Show("管理处名称不能为空!");
                    return;
                }

                string strSql = "";
                if (this.m_bEdit == true)
                {
                    strSql = String.Format("delete from tbDep where depShortName='{0}'", this.txtDepShortName.Text.Trim());
                    CDBConnection.ExecuteSql(strSql);
                }


                strSql = String.Format("select count(*) from tbDep where depName='{0}'", this.txtDepName.Text.Trim());
                string strCount = CDBConnection.ExecuteScalar(strSql);
                int    iCount   = Convert.ToInt32(strCount);
                if (iCount > 0)
                {
                    MessageBox.Show("该管理处名称已存在!");
                    return;
                }

                strSql   = String.Format("select count(*) from tbDep where depShortName='{0}'", this.txtDepShortName.Text.Trim());
                strCount = CDBConnection.ExecuteScalar(strSql);
                if (strCount != "0")
                {
                    MessageBox.Show("该管理处简称已存在!");
                    return;
                }

                strSql = String.Format("insert into tbDep(DepShortName,depName,countryName,hangYeName,contactPer,contactTel,address,des) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", this.txtDepShortName.Text.Trim(), this.txtDepName.Text.Trim(), this.cmbCountry.Text.Trim(), this.cmbHangYe.Text.Trim(), this.txtContactPer.Text.Trim(), this.txtContactTel.Text.Trim(), this.txtAddress.Text.Trim(), this.txtDes.Text.Trim());
                CDBConnection.ExecuteSql(strSql);

                this.m_bInserted = true;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 9
0
        private void btnDel_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.lsvHangYe.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选中要删除的行业!");
                    return;
                }


                string strHangYeName = this.lsvHangYe.SelectedItems[0].Text.Trim();
                string strSql        = String.Format("delete from tbHangYe where HangYeName='{0}'", strHangYeName);
                CDBConnection.ExecuteSql(strSql);

                this.paintFrm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 10
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.lswUserInfo.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选中一名用户!");
                    return;
                }

                string strUserID = this.lswUserInfo.SelectedItems[0].Text.Trim();
                string strSql    = String.Format("delete from userMenu where UserID='{0}'", strUserID);
                CDBConnection.ExecuteSql(strSql);

                for (int i = 0; i < this.tvwMenuInfo.Nodes.Count; i++)
                {
                    if (this.tvwMenuInfo.Nodes[i].Checked)
                    {
                        string strMenu = this.tvwMenuInfo.Nodes[i].Text.Trim();
                        strSql = String.Format("insert into userMenu(userID,MenuName) values('{0}','{1}')", strUserID, strMenu);
                        CDBConnection.ExecuteSql(strSql);
                    }
                    for (int j = 0; j < this.tvwMenuInfo.Nodes[i].Nodes.Count; j++)
                    {
                        if (this.tvwMenuInfo.Nodes[i].Nodes[j].Checked)
                        {
                            string strMenuChild = this.tvwMenuInfo.Nodes[i].Nodes[j].Text.Trim();
                            strSql = String.Format("insert into userMenu(userID,MenuName) values('{0}','{1}')", strUserID, strMenuChild);
                            CDBConnection.ExecuteSql(strSql);
                        }
                    }
                }
                MessageBox.Show("权限设置成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 11
0
        private bool SaveDatas()
        {
            try
            {
                string strPrice  = this.txtPrice.Text.Trim();
                string strMony   = this.txtMony.Text.Trim();
                string strAmount = this.txtAmount.Text.Trim();

                string strPer  = CDBConnection.m_strUserName;
                string strTime = System.DateTime.Now.ToString();

                string strWellNo = this.txtWellNo.Text.Trim();

                string strSql = String.Format("insert into tbSal(wellNo,price,salMony,salAmount,time,salPer) values('{0}','{1}','{2}','{3}','{4}','{5}')", strWellNo, strPrice, strMony, strAmount, strTime, strPer);
                CDBConnection.ExecuteSql(strSql);

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Exemplo n.º 12
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.m_bEdit)
                {
                    DialogResult result = MessageBox.Show(this, "警告:修改站点信息将对实时监测和报表统计造成影响是否继续?", "系统提示", MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
                                                          MessageBoxOptions.RightAlign);

                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                    else
                    {
                    }
                }

                if (this.chkJTS.Checked)
                {
                    if (!this.paintPrice())
                    {
                        return;
                    }
                }

                if (this.txtPrice.Text.Trim() == "")
                {
                    MessageBox.Show("水价不能为空!");
                    return;
                }

                if (this.txtWatNo.Text.Trim() == "")
                {
                    MessageBox.Show("请填入控制器编号。");
                    return;
                }

                try
                {
                    double dPrice = double.Parse(this.txtPrice.Text.Trim());
                }
                catch
                {
                    MessageBox.Show("水价不是有效数字!");
                    return;
                }

                string strSqlE  = string.Format("select count(*) from tbWell where watchNo='{0}' and not wellNo='{1}'", this.txtWatNo.Text.Trim(), this.txtWellNo.Text.Trim());
                string strCount = BengZhan.CDBConnection.ExecuteScalar(strSqlE);
                if (strCount.Trim() != "0")
                {
                    MessageBox.Show("该控制器编号已录入!");
                    return;
                }

                if (this.txtWellName.Text.Trim() == "")
                {
                    MessageBox.Show("请填入监测站名称!");
                    return;
                }

                if (this.txtGprsNo.Text.Trim() == "")
                {
                    MessageBox.Show("请输入GPRS号!");
                    return;
                }

                if (this.txtAddress.Text.Trim() == "")
                {
                    MessageBox.Show("请输入设备地址!");
                    return;
                }
                if (this.txtGprsNo.Text.Trim().Length != 11)
                {
                    MessageBox.Show("GPRS号长度有误!");
                    return;
                }

                string strSql    = String.Format("select count(*) from tbWell where wellName='{0}' and not wellNo='{1}'", this.txtWellName.Text.Trim(), this.txtWellNo.Text.Trim());
                string strCountE = CDBConnection.ExecuteScalar(strSql);
                if (strCountE.Trim() != "0")
                {
                    MessageBox.Show("该监测站名称已录入!");
                    return;
                }

                strSql   = String.Format("select count(*) from tbWell where gprsNo='{0}' and not wellNo='{1}'", this.txtGprsNo.Text.Trim(), this.txtWellNo.Text.Trim());
                strCount = CDBConnection.ExecuteScalar(strSql);
                if (strCount != "0")
                {
                    MessageBox.Show("该GPRS号已存在!");
                    return;
                }

                string strWatchType = "";

                strSql       = String.Format("select watchType from tbWell where wellNo='{0}'", this.txtWellNo.Text.Trim());
                strWatchType = BengZhan.CDBConnection.ExecuteScalar(strSql);

                strSql = String.Format("delete from tbWell where wellNo='{0}'", this.txtWellNo.Text.Trim());
                CDBConnection.ExecuteSql(strSql);

                string strX = "";
                if (this.txtX.Text.Trim() == "")
                {
                    strX = "null";
                }
                else
                {
                    try
                    {
                        double dX = Convert.ToDouble(this.txtX.Text.Trim());
                        strX = dX.ToString();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("你所填入的x坐标不是有效数字!");
                        return;
                    }
                }

                string strY = "";
                if (this.txtY.Text.Trim() == "")
                {
                    strY = "null";
                }
                else
                {
                    try
                    {
                        double dY = Convert.ToDouble(this.txtY.Text.Trim());
                        strY = dY.ToString();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("你所填入的x坐标不是有效数字!");
                        return;
                    }
                }

                //地址十六进制
                string strAddress = this.txtAddress.Text.Trim();
                int    iAddress   = Convert.ToInt32(strAddress, 16);
                strAddress = iAddress.ToString();

                strSql = String.Format("insert into tbWell(wellNo,wellName,depName,gprsNo,watAddress,wellDes,x,y,ICNo,watchType) values('{0}','{1}','{2}','{3}','{4}','{5}',{6},{7},'{8}','{9}')", this.txtWellNo.Text.Trim(), this.txtWellName.Text.Trim(), this.txtDepShortName.Text.Trim(), this.txtGprsNo.Text.Trim(), strAddress, this.txtDes.Text.Trim(), strX, strY, this.txtICNo.Text.Trim(), strWatchType);
                CDBConnection.ExecuteSql(strSql);

                strSql = String.Format("delete from tbDel where tbName='{0}' and tbNo='{1}'", "tbWell", this.txtWellNo.Text.Trim());
                CDBConnection.ExecuteSql(strSql);

                strSql = string.Format("update tbWell set iniAmount='{0}',watchNo='{1}',xi='{2}',warnAmount='{3}',price1='{5}' where wellNo='{4}'", this.txtIniAmount.Text.Trim(), this.txtWatNo.Text.Trim(), this.txtXi.Text.Trim(), this.txtWarnLevel.Text.Trim(), this.txtWellNo.Text.Trim(), this.txtPrice.Text.Trim());
                BengZhan.CDBConnection.ExecuteSql(strSql);


                if (this.chkJTS.Checked)
                {
                    strSql = string.Format("update tbWell set bjt='true' where wellNo='{0}'", this.txtWellNo.Text.Trim());
                    BengZhan.CDBConnection.ExecuteSql(strSql);
                    this.saveJTPrice();
                }

                this.m_bInserted = true;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 13
0
        private void btnDel_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (MessageBox.Show("删除操作可能对数据统计造成影响,是否继续?", "删除", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }

                //return;

                if (this.lsvWell.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请选中要删除的监测站!");
                    return;
                }

                string strWellNo = this.lsvWell.SelectedItems[0].Text.Trim();

                string strSql   = String.Format("select count(*) from (select * from tbWellAmount where wellNo='{0}' union select * from tbWellAmount where wellNo='{0}') temp", strWellNo);
                string strCount = CDBConnection.ExecuteScalar(strSql);

//				if(strCount!="")
//				{
//					int iCount=Convert.ToInt32(strCount);
//					if(iCount>0)
//					{
//						if(MessageBox.Show("流量信息表中已有该监测站的信息,继续操作将造成历史记录混乱,是否继续?","删除",MessageBoxButtons.OKCancel)!=DialogResult.OK)
//						{
//							return;
//						}
//
//					}
//				}

                strSql   = String.Format("select count(*) from tbSal where wellNo='{0}'", strWellNo);
                strCount = CDBConnection.ExecuteScalar(strSql);
//				if(strCount!="")
//				{
//					int iCount=Convert.ToInt32(strCount);
//					if(iCount>0)
//					{
//						if(MessageBox.Show("售水历史记录表中已有该监测站的信息,继续操作将造成历史记录混乱,是否继续?","删除",MessageBoxButtons.OKCancel)!=DialogResult.OK)
//						{
//							return;
//						}
//
//					}
//				}


                strSql = String.Format("delete from tbWell where wellNo='{0}'", strWellNo);
                CDBConnection.ExecuteSql(strSql);

                strSql = String.Format("delete from tbw_WellInfo where WellID='{0}'", strWellNo);
                CDBConnection.ExecuteSql(strSql);
//
                strSql = String.Format("insert into tbDel(tbNo,tbName) values('{0}','{1}')", strWellNo, "tbWell");
                CDBConnection.ExecuteSql(strSql);

                this.paintFrm();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }