Пример #1
0
        public void RemoveYeZhu(YeZhu yz)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            string jsonData         = js.Serialize(yz);//序列化

            DataFormServer("action=remove&data=" + ed(jsonData));
        }
Пример #2
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            this.tbLog.Clear();
            List <int> buildings = Common.ParserNum(this.tbBuilding.Text);
            List <int> rooms     = Common.ParserNum(this.tbRoom.Text);

            if (buildings.Count == 0 || rooms.Count == 0)
            {
                MessageBox.Show("楼栋或室号有误,请检查"); return;
            }

            List <YeZhu> all = Config.DataManager.GetYeZhuAll();

            foreach (int b in buildings)
            {
                for (int i = 1; i <= this.nudFloor.Value; i++)
                {
                    foreach (int r in rooms)
                    {
                        string room = string.Format("{0}{1}", i, r.ToString().PadLeft(2, '0'));
                        YeZhu  yz   = all.Find(c => c.building == b && c.room == room);
                        if (yz == null)
                        {
                            this.tbLog.AppendText(string.Format("楼栋{0},室号{1}\r\n", b, room));
                        }
                    }
                }
            }
        }
Пример #3
0
        public void UpdateYeZhu(YeZhu yz)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            string jsonData         = js.Serialize(yz);//序列化

            DataFormServer("action=update&data=" + System.Web.HttpUtility.UrlEncode(jsonData, System.Text.Encoding.UTF8));
        }
Пример #4
0
 public void RemoveYeZhu(YeZhu yz)
 {
     if (Config.Conn.State == System.Data.ConnectionState.Closed)
     {
         Config.Conn.Open();
     }
     DB.Delete(yz);
 }
Пример #5
0
 private void lsvData_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lsvData.SelectedItems.Count > 0)
     {
         ListViewItem lvi = lsvData.SelectedItems[0];
         YeZhu        yz  = lvi.Tag as YeZhu;
         this.tbDetail.Text = yz.ToString();
     }
 }
Пример #6
0
 public void UpdateYeZhu(YeZhu yz)
 {
     if (yz.log == null)
     {
         yz.log = "";
     }
     if (Config.Conn.State == System.Data.ConnectionState.Closed)
     {
         Config.Conn.Open();
     }
     DB.Update(yz);
 }
Пример #7
0
 private void tsmiDeleteYeZhu_Click(object sender, EventArgs e)
 {
     if (lsvData.SelectedItems.Count > 0)
     {
         ListViewItem lvi = lsvData.SelectedItems[0];
         YeZhu        yz  = lvi.Tag as YeZhu;
         if (MessageBox.Show(string.Format("确认删除{0}楼{1}室信息,删除后不可恢复,需要请重新添加", yz.building, yz.room), "删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
         {
             Config.DataManager.RemoveYeZhu(yz);
             lvi.Remove();
         }
     }
 }
Пример #8
0
        /// <summary>
        /// 生成lvi
        /// </summary>
        /// <param name="yz"></param>
        /// <returns></returns>
        private ListViewItem getlvi(YeZhu yz)
        {
            ListViewItem lvi = new ListViewItem(yz.building.ToString());

            lvi.Tag = yz;
            lvi.SubItems.Add(yz.room);
            lvi.SubItems.Add(yz.owner);
            lvi.SubItems.Add(yz.phone);
            lvi.SubItems.Add(yz.qq);
            lvi.SubItems.Add(yz.area);
            lvi.SubItems.Add(yz.GetUsed());
            lvi.SubItems.Add(yz.bak);
            return(lvi);
        }
Пример #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            List <int>   buildings = Common.ParserNum(this.tbBuilding.Text);
            List <int>   rooms     = Common.ParserNum(this.tbRoom.Text);
            List <YeZhu> all       = Config.DataManager.GetYeZhuAll();

            if (buildings.Count == 0 || rooms.Count == 0)
            {
                MessageBox.Show("楼栋或室号有误,请检查"); return;
            }



            List <YeZhu> adds = new List <YeZhu>();

            foreach (int b in buildings)
            {
                for (int i = 1; i <= this.nudFloor.Value; i++)
                {
                    foreach (int r in rooms)
                    {
                        string room = string.Format("{0}{1}", i, r.ToString().PadLeft(2, '0'));
                        YeZhu  yz   = all.Find(c => c.building == b && c.room == room);
                        if (yz == null)
                        {
                            yz          = new YeZhu();
                            yz.building = b;
                            yz.room     = room;
                            adds.Add(yz);
                        }
                    }
                }
            }
            if (adds.Count > 0)
            {
                Config.DataManager.AddYeZhu(adds);
            }

            MessageBox.Show(string.Format("本次添加成功房屋{0}间", adds.Count));
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Пример #10
0
 private void lsvData_DoubleClick(object sender, EventArgs e)
 {
     if (lsvData.SelectedItems.Count == 1)
     {
         ListViewItem lvi   = lsvData.SelectedItems[0];
         int          index = lsvData.SelectedIndices[0];
         YeZhu        yz    = (lvi.Tag as YeZhu).Clone();
         FrmEdit      f2    = new FrmEdit(yz);
         if (f2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 Config.DataManager.UpdateYeZhu(yz);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "更新失败");
             }
             lvi.Remove();
             lvi = getlvi(yz);
             this.lsvData.Items.Insert(index, lvi);
         }
     }
 }
Пример #11
0
 public FrmEdit(YeZhu yz)
 {
     InitializeComponent();
     this.yz = yz;
 }