Ejemplo n.º 1
0
 private void yfBtnDel_Click(object sender, EventArgs e)
 {
     //删除源房
     if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag is SourceRoom)
     {
         SourceRoom yf     = treeView1.SelectedNode.Tag as SourceRoom;
         string     txt    = string.Format("确定要删除源房 [{0}] 吗?\r\n(将同时删除此源房下面的所有客房及所有关联的信息)", yf.房名);
         var        result = KryptonMessageBox.Show(txt, "源房删除确认",
                                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,
                                                    MessageBoxDefaultButton.Button2);
         if (result == DialogResult.OK)
         {
             context.SourceRoom.Remove(yf);
             string msg;
             if (Helper.saveData(context, yf, out msg))
             {
                 KryptonMessageBox.Show(msg, "成功删除源房");
                 RefreshAndLocateTree(null);
                 LoadOrRefreshUC(null);
             }
             else
             {
                 KryptonMessageBox.Show(msg, "失败");
                 context.Entry(yf).Reload();//重新从数据库加载
             }
         }
     }
 }
Ejemplo n.º 2
0
        private bool isNew;//是否是新增

        /// <summary>
        /// 新增源房
        /// </summary>
        public 源房Form()
        {
            InitializeComponent();
            isNew   = true;
            this.yf = SourceRoom.MyCreate();
            context.SourceRoom.Add(yf);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 加入一个树节点
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="yf"></param>
        /// <param name="isHistory">是否是历史源房(历史源房下的客房不管到期与否都置灰)</param>
        private void AddYuanFangToTree(TreeNode parent, SourceRoom yf, bool isHistory, Object obj)
        {
            TreeNode yfNode = new TreeNode();

            yfNode.Text       = yf.房名;
            yfNode.Tag        = yf;
            yfNode.ImageIndex = isHistory ? 5 : 2;//历史源房5:当前有效源房2
            DoThreadSafe(delegate {
                parent.Nodes.Add(yfNode);
                if (yf == obj)
                {
                    yfNode.TreeView.SelectedNode = yfNode;
                }
            });

            var kfs = yf.GuestRoom;

            foreach (var kf in kfs)
            {
                TreeNode kfNode = new TreeNode();
                kfNode.Text = kf.命名;
                kfNode.Tag  = kf;
                if (isHistory)
                {
                    kfNode.ImageIndex = 6;//历史客房
                }
                else
                {
                    if (string.IsNullOrEmpty(kf.租户))
                    {
                        kfNode.ImageIndex = 4;//未租4
                    }
                    else
                    {
                        kfNode.ImageIndex = 3;    //已租3

                        if (kf.期止 < DateTime.Now) //已租,协议到期,请续租或退租
                        {
                            kfNode.Text       += "[协议到期]";
                            kfNode.ToolTipText = "协议到期,请[续租]或[退租]。";
                            kfNode.ForeColor   = Color.Red;
                        }
                        else if (kf.GuestRoomRentalDetail.Count == 0 || kf.GuestRoomRentalDetail.Max(m => m.止付日期) < DateTime.Now)//已租,协议未到期,逾期交租
                        {
                            kfNode.Text       += "[逾期交租]";
                            kfNode.ToolTipText = "逾期交租,请[收租]或[退租]。";
                            kfNode.ForeColor   = Color.Magenta;
                        }
                    }
                }
                DoThreadSafe(delegate {
                    yfNode.Nodes.Add(kfNode);
                    if (kf == obj)
                    {
                        kfNode.TreeView.SelectedNode = kfNode;
                    }
                });
            }
        }
Ejemplo n.º 4
0
        private void 源房涨租协定BindingSource_AddingNew(object sender, System.ComponentModel.AddingNewEventArgs e)
        {
            SourceRoomUpRentalAgreement obj = new SourceRoomUpRentalAgreement();
            SourceRoom temp = 源房BindingSource.DataSource as SourceRoom;

            //obj.源房ID = temp.ID;
            obj.SourceRoom = temp;//同步外键引用
            e.NewObject    = obj;
        }
Ejemplo n.º 5
0
 private void yfBtnEdit_Click(object sender, EventArgs e)
 {
     //编辑源房
     if (treeView1.SelectedNode != null && treeView1.SelectedNode.Tag is SourceRoom)
     {
         SourceRoom yf = treeView1.SelectedNode.Tag as SourceRoom;
         using (源房Form yF = new 源房Form(yf.ID))
         {
             yF.ShowDialog(this);
         }
     }
 }
Ejemplo n.º 6
0
        private void 源房BindingSource_DataSourceChanged(object sender, EventArgs e)
        {
            SourceRoom yf = 源房BindingSource.DataSource as SourceRoom;

            //临时Detach现有的所有SourceRoomUpRentalAgreement本地对象
            foreach (var o in parentContext.SourceRoomUpRentalAgreement.Local.ToList())
            {
                parentContext.Entry(o).State = System.Data.EntityState.Detached;
            }

            yf.SourceRoomUpRentalAgreement.OrderBy(m => m.期始).AsQueryable().Load();
            源房涨租协定BindingSource.DataSource = parentContext.SourceRoomUpRentalAgreement.Local.ToBindingList();
        }
Ejemplo n.º 7
0
        private void buttonSpecAny阶梯电价_Click(object sender, EventArgs e)
        {
            SourceRoom yf = 源房BindingSource.DataSource as SourceRoom;

            using (阶梯电价Form f = new 阶梯电价Form(yf.阶梯电价))
            {
                DialogResult dr = f.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    yf.阶梯电价 = f.ResultElectricValue;
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 加载源房、客房信息到TreeView控件。
        /// 同时如果传入了Object[例如:某个源房、客房对象],加载后则选中之。
        /// </summary>
        private void LoadTreeView(Object obj)
        {
            if (context.SourceRoom.Count() > 0)
            {
                DoThreadSafe(delegate {
                    treeView1.BeginUpdate();
                    treeView1.Nodes.Clear();
                });


                TreeNode root1 = new TreeNode("当前源房信息");
                root1.ToolTipText = "当前源房按照签约时间自动排序";
                root1.NodeFont    = new System.Drawing.Font("宋体", 10, FontStyle.Bold);
                root1.ImageIndex  = 0;
                DoThreadSafe(delegate { treeView1.Nodes.Add(root1); });
                foreach (var yf in SourceRoom.GetYF_NoHistory(context))
                {
                    AddYuanFangToTree(root1, yf, false, obj);
                }

                TreeNode root2 = new TreeNode("历史源房信息");
                root2.ToolTipText = "历史源房按照签约时间自动排序";
                root2.NodeFont    = new System.Drawing.Font("宋体", 10, FontStyle.Bold);
                root2.ForeColor   = Color.DimGray;
                root2.ImageIndex  = 1;
                DoThreadSafe(delegate { treeView1.Nodes.Add(root2); });
                foreach (var yf in SourceRoom.GetYF_History(context))
                {
                    AddYuanFangToTree(root2, yf, true, obj);
                }

                DoThreadSafe(delegate {
                    treeView1.ExpandAll();
                    treeView1.EndUpdate();
                });
            }
            else
            {
                DoThreadSafe(delegate { treeView1.Nodes.Add("当前没有源房、客房信息"); });
            }
        }
Ejemplo n.º 9
0
        private void buttonSpecAny气单价_Click(object sender, EventArgs e)
        {
            SourceRoom yf = 源房BindingSource.DataSource as SourceRoom;

            yf.气单价 = Convert.ToDecimal(Landlord2.Properties.Resources.武汉市天然气价默认值);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 编辑源房
 /// </summary>
 public 源房Form(Guid yfID)
 {
     InitializeComponent();
     isNew   = false;
     this.yf = context.SourceRoom.Find(yfID);
 }