⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 facilityspanel.cs

📁 社区管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DataBaseManagerLibrary;

namespace GGSSManeger
{
    public partial class FacilitysPanel : UserControl
    {
        private DataBaseManager DBManager;
        private Int64 dealID, insertDealID;
        private int selectedIndex;

        public FacilitysPanel()
        {
            InitializeComponent();
            reset();
            //setDataBaseManager(null);
        }

        public void visilize()
        {
            reset();    //将各个控件置为初始状态
            this.Visible = true;
        }

        public void disVisilize()
        {
            this.Visible = false;
        }

        private void reset() //
        {
            dealID = 0;
            selectedIndex = -1;
         //  btXiug_sheshi.Enabled = false;
         //   btDel_sheshi.Enabled = false;
            tb_sheshiName.Text = "";
            tb_chengjian.Text = "";
            tb_fuzhe.Text = "";
            tb_jiaofutime.Text = "";
            tb_SSnum.Text = "";
            tb_sheshiM.Text = "";
            tb_tel.Text = "";
            tb_useM.Text = "";
            tb_useNofP.Text = "";
            tb_user.Text = "";
            tb_usestate.Text = "";
            tb_usetime.Text = "";
            

        }

        public void setDataBaseManager(DataBaseManager DBManager)
        {
            //String SqlConnectInfo = "server=(local);database=CommunityManagementSystem;uid=sa;pwd='586925'";
            //DBManager = new DataBaseManager(SqlConnectInfo);
            this.DBManager = DBManager;
            DataTable dt = DBManager.ExecuteSelectCommand("select 设施编号,设施名称,承建商,电话,负责人,交付日期,使用人员名称,使用时间,使用次数,使用状态,使用金额,设施金额 from 设施信息");
            if (dt == null) MessageBox.Show(DBManager.errorMessage);
            dataGridView1.DataSource = dt;
        }

        private bool ErrorMessage(String msg)
        {
            MessageBox.Show(msg);
            return false;
        }
       
        private bool checkInput(String str)
        {   tb_sheshiName.Text=tb_sheshiName.Text.Trim();
            tb_sheshiM.Text=tb_sheshiM.Text.Trim();
            tb_SSnum.Text=tb_SSnum.Text.Trim();
            tb_jiaofutime.Text=tb_jiaofutime.Text.Trim();
            tb_chengjian.Text=tb_chengjian.Text.Trim();
            tb_fuzhe.Text=tb_fuzhe.Text.Trim();
            tb_tel.Text=tb_tel.Text.Trim();
            tb_useM.Text=tb_useM.Text.Trim();
            tb_useNofP.Text=tb_useNofP.Text.Trim();
            tb_user.Text=tb_user.Text.Trim();
            tb_usestate.Text=tb_usestate.Text.Trim();
            tb_usetime.Text=tb_usetime.Text.Trim();

            if (str == "Insert" || str == "Modify")
            {//以下是在更新或插入时检查输入是否为空
                if (tb_sheshiName.Text == "") return ErrorMessage("设施名为空");
                if (tb_sheshiM.Text == "") return ErrorMessage("设施金额为空");
                if (tb_SSnum.Text == "") return ErrorMessage("设施编号为空");
                if (tb_jiaofutime.Text == "") return ErrorMessage("交付日期为空");
                if (tb_chengjian.Text == "") return ErrorMessage("承建商为空");
                if (tb_fuzhe.Text == "") return ErrorMessage("负责人为空");
                if (tb_tel.Text == "") return ErrorMessage("电话为空");

                if (tb_useM.Text == "") return ErrorMessage("使用金额为空");
                if (tb_useNofP.Text == "") return ErrorMessage("使用人数为空");
                if (tb_user.Text == "") return ErrorMessage("使用人员为空");
                if (tb_usestate.Text == "") return ErrorMessage("使用状态为空");
                if (tb_usetime.Text == "") return ErrorMessage("使用时间为空");
                if (tb_SSnum.Text == "") return ErrorMessage("设施编号为空");
            }

            if (tb_usestate.Text != "")
            {
                String s = tb_usestate.Text;
                if (s != "免费" && s != "付费") return ErrorMessage("使用状态输入错误");
            }

            try
            {
                if (tb_sheshiM.Text != "")
                    float.Parse(tb_sheshiM.Text);
            }
            catch 
            { 
                return ErrorMessage("设施金额输入错误");
            }

            try
            {
                if (tb_useM.Text !="")
                    float.Parse(tb_useM.Text);
            }
            catch 
            {
                return ErrorMessage("使用金额输入错误");
            }
            try
            {
                if (tb_useNofP.Text != "")
                    Int64.Parse(tb_useNofP.Text);
            }
            catch 
            {
                return ErrorMessage("使用人数输入错误"); 
            }
            try
            {
                if (tb_tel.Text != "")
                    Int64.Parse(tb_tel.Text);
            }
            catch
            {
                return ErrorMessage("电话输入错误");
            }
            try
            {
                if (tb_SSnum.Text != "")
                    Int64.Parse(tb_SSnum.Text);
            }
            catch
            {
                return ErrorMessage("设施编号输入错误");
            }
 /*             try
            {
                if (tb_jiaofutime.Text != "")
                    Int64.Parse(tb_jiaofutime.Text);
            }
            catch
            {
                return ErrorMessage("交付日期输入错误");
            }
          try
            {
                if (tb_usetime.Text != "")
                    Int64.Parse(tb_usetime.Text);
            }
            catch
            {
                return ErrorMessage("使用时间输入错误");
            }*/


            
            return true;
        }
    
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.RowIndex >= dataGridView1.Rows.Count - 1) return; //选择多行或选择列标签
            showDetailInfo(e.RowIndex);
            selectedIndex = e.RowIndex;

            tb_SSnum.Text = (dataGridView1.Rows[selectedIndex].Cells["设施编号"].Value).ToString();
            tb_sheshiName.Text = (dataGridView1.Rows[selectedIndex].Cells["设施名称"].Value).ToString();
            tb_chengjian.Text = (dataGridView1.Rows[selectedIndex].Cells["承建商"].Value).ToString();
            tb_tel.Text = (dataGridView1.Rows[selectedIndex].Cells["电话"].Value).ToString();
            tb_fuzhe.Text = (dataGridView1.Rows[selectedIndex].Cells["负责人"].Value).ToString();
            tb_jiaofutime.Text = (dataGridView1.Rows[selectedIndex].Cells["交付日期"].Value).ToString();
            tb_user.Text = (dataGridView1.Rows[selectedIndex].Cells["使用人员名称"].Value).ToString();
            tb_usetime.Text = (dataGridView1.Rows[selectedIndex].Cells["使用时间"].Value).ToString();
            tb_useNofP.Text = (dataGridView1.Rows[selectedIndex].Cells["使用次数"].Value).ToString();
            tb_usestate.Text = (dataGridView1.Rows[selectedIndex].Cells["使用状态"].Value).ToString();
            tb_useM.Text = (dataGridView1.Rows[selectedIndex].Cells["使用金额"].Value).ToString();
            tb_sheshiM.Text = (dataGridView1.Rows[selectedIndex].Cells["设施金额"].Value).ToString();

        }
    
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {


        }
   
        private void showDetailInfo(int idx)
        {
            if (idx < 0) return;
            selectedIndex = idx;
            dealID = (Int64)dataGridView1.Rows[idx].Cells["设施编号"].Value;//得到用户选择的行的主键
            DataTable dt = DBManager.ExecuteSelectCommand(String.Format("select 设施编号,设施名称,承建商,电话,负责人,交付日期,使用人员名称,使用时间,使用次数,使用状态,使用金额,设施金额 from 设施信息 where 设施编号='{0}'", dealID));
            if (dt == null)
            {//数据库错误
                MessageBox.Show(DBManager.errorMessage);
                dealID = 0;
                return;
            }
            else if (dt.Rows.Count == 0)
            {  //未找到此记录
                MessageBox.Show("此记录可能已被其他用户删除");
                dealID = 0;
                return;
            }

        }
       
        private String generateSelectCommand()
        {
            String cmds = "Select 设施编号,设施名称,承建商,电话,负责人,交付日期,使用人员名称,使用时间,使用次数,使用状态,使用金额,设施金额 from 设施信息 ";
            String cmd = "";
     //       bool cmdChanged = false;
             if (tb_SSnum.Text != "")
                 cmd = cmd + " where 设施编号='" + tb_SSnum.Text + "'";
       
      /*      if (tb_sheshiName.Text != "")
            {
                if (cmdChanged) cmd = cmd + " and 设施名称='" + tb_sheshiName.Text + "'";
                else
                {
                    cmdChanged = true;
                    cmd = cmd + "where 设施名称='" + tb_sheshiName.Text + "'";
                }
            }
            if (tb_chengjian.Text != "")
            {
                if (cmdChanged) cmd = cmd + " and 承建商='" + tb_chengjian.Text + "'";
                else
                {
                    cmdChanged = true;
                    cmd = cmd + "where 承建商='" + tb_chengjian.Text + "'";
                }
            }

            
            if (tb_tel.Text != "")

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -