/// <summary> /// 右键点击前事件 /// </summary> /// <param name="sender">事件对象</param> /// <param name="e">事件参数</param> private void t_pgg_Bill_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { try { ArrayList statusList = new ArrayList(); statusList.Add("已入库"); statusList.Add("回收站"); statusList.Add("归档"); XTreeNode myItem = t_tvw_Module.SelectedItem as XTreeNode; string myTag = string.Empty; string parentTag = string.Empty; if (myItem == null && m_MQuery != null) { myTag = m_MQuery.BillType; } else { myTag = myItem.Tag.ToString(); if (myItem.Parent != null) { parentTag = myItem.Parent.Tag.ToString(); } } string billStatus = string.Empty; if (myTag == "Q" || parentTag == "Q") { PT_B_Quotation myModel = (PT_B_Quotation)t_pgg_Bill.SelectedItem; statusList.Remove(SetBillStatus(myModel.Bill_Status)); billStatus = "Q"; } else { PT_B_Project myModel = (PT_B_Project)t_pgg_Bill.SelectedItem; statusList.Remove(SetBillStatus(myModel.Bill_Status)); billStatus = "P"; } t_tsb_ChangeState.Items.Clear(); foreach (string status in statusList) { MenuItem item = new MenuItem(); item.Header = status; item.Tag = billStatus; item.Click += Item_Click; t_tsb_ChangeState.Items.Add(item); } } catch (Exception ex) { XMessageBox.Exception(ex); } }
/// <summary> /// 表格行鼠标双击事件 /// </summary> /// <param name="sender">事件对象</param> /// <param name="e">事件参数</param> private void t_pgg_Bill_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (t_pgg_Bill.SelectedItem == null) { return; } XTreeNode myItem = t_tvw_Module.SelectedItem as XTreeNode; string myTag = string.Empty; string parentTag = string.Empty; if (myItem == null && m_MQuery != null) { myTag = m_MQuery.BillType; } else { myTag = myItem.Tag.ToString(); if (myItem.Parent != null) { parentTag = myItem.Parent.Tag.ToString(); } } if (myTag == "Q" || parentTag == "Q") { PT_B_Quotation myModel = (PT_B_Quotation)t_pgg_Bill.SelectedItem; FrmQuotation myForm = new FrmQuotation(); myForm.PTBQuotation = myModel; myForm.ShowDialog(); m_Entities.Dispose(); m_Entities = new ProjectTrackingEntities(); RefreshTreeNode(); } else { PT_B_Project myModel = (PT_B_Project)t_pgg_Bill.SelectedItem; FrmProject myForm = new FrmProject(); myForm.PTBProject = myModel; myForm.ShowDialog(); m_Entities.Dispose(); m_Entities = new ProjectTrackingEntities(); RefreshTreeNode(); } } catch (Exception ex) { XMessageBox.Exception(ex); } }
/// <summary> /// 生成项目单 /// </summary> /// <param name="sender">事件对象</param> /// <param name="e">事件参数</param> private void t_tsb_CreateProject_Click(object sender, RoutedEventArgs e) { try { if (m_IsModify || t_txt_QuotationNo.Text == "新单") { XMessageBox.Enter("当前单据尚未保存,请保存后再操作!", this); return; } m_IsModify = false; this.Visibility = Visibility.Hidden; PT_B_Project myModel = new PT_B_Project(); myModel.Project_Id = Guid.NewGuid().ToString("N"); myModel.Quotation_No = PTBQuotation.Quotation_No; myModel.Quotation_Date = PTBQuotation.Quotation_Date; myModel.Follow_Man = PTBQuotation.Follow_Man; myModel.Product_Model = PTBQuotation.Product_Model; myModel.Project_Name = PTBQuotation.Project_Name; myModel.Price = PTBQuotation.Price; myModel.Is_Tax = PTBQuotation.Is_Tax; myModel.Project_Type = PTBQuotation.Quotation_Type; myModel.Cycle_Time = PTBQuotation.Cycle_Time; myModel.Company_Name = PTBQuotation.Company_Name; myModel.Company_Address = PTBQuotation.Company_Address; myModel.Contact_Man = PTBQuotation.Contact_Man; myModel.Tel = PTBQuotation.Tel; myModel.Email = PTBQuotation.Email; myModel.Fax = PTBQuotation.Fax; myModel.Remark = PTBQuotation.Remark; myModel.Oper_Time = DateTime.Now; myModel.Account_Receivable = PTBQuotation.Price; myModel.Profits = PTBQuotation.Price; FrmProject myForm = new FrmProject(); myForm.PTBProject = myModel; myForm.ShowDialog(); this.Close(); } catch (Exception ex) { XMessageBox.Exception(ex); } }
/// <summary> /// 项目单窗口双击事件 /// </summary> /// <param name="sender">事件对象</param> /// <param name="e">事件参数</param> private void t_dge_Project_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (t_dge_Project.Items.Count == 0) { return; } this.Visibility = Visibility.Hidden; PT_B_Project myModel = (PT_B_Project)t_dge_Project.SelectedItem; FrmProject myForm = new FrmProject(); myForm.PTBProject = myModel; myForm.ShowDialog(); this.Close(); } catch (Exception ex) { XMessageBox.Exception(ex); } }
/// <summary> /// 改变状态方法 /// </summary> /// <param name="sender">事件对象</param> /// <param name="e">事件参数</param> private void Item_Click(object sender, RoutedEventArgs e) { try { MenuItem myItem = sender as MenuItem; if (myItem.Tag.ToString() == "Q") { PT_B_Quotation myModel = (PT_B_Quotation)t_pgg_Bill.SelectedItem; string mes = string.Format("确定将此单据状态修改为【{0}】", myItem.Header.ToString()); MessageResult myResult = XMessageBox.Ask(mes, this); if (myResult == MessageResult.Yes) { myModel.Bill_Status = SetBillStatus(myItem.Header.ToString()); m_Entities.SaveChanges(); RefreshTreeNode(); } } else { PT_B_Project myModel = (PT_B_Project)t_pgg_Bill.SelectedItem; string mes = string.Format("确定将此单据状态修改为【{0}】", myItem.Header.ToString()); MessageResult myResult = XMessageBox.Ask(mes, this); if (myResult == MessageResult.Yes) { myModel.Bill_Status = SetBillStatus(myItem.Header.ToString()); m_Entities.SaveChanges(); RefreshTreeNode(); } } } catch (Exception ex) { XMessageBox.Exception(ex); } }
/// <summary> /// 删除按钮事件 /// </summary> /// <param name="sender">事件对象</param> /// <param name="e">事件参数</param> private void t_btn_Delete_Click(object sender, RoutedEventArgs e) { try { if (t_pgg_Bill.SelectedItem == null) { XMessageBox.Warning("未选中一条单据!", this); return; } XTreeNode myItem = t_tvw_Module.SelectedItem as XTreeNode; string myTag = string.Empty; string parentTag = string.Empty; if (myItem == null && m_MQuery != null) { myTag = m_MQuery.BillType; } else { myTag = myItem.Tag.ToString(); if (myItem.Parent != null) { parentTag = myItem.Parent.Tag.ToString(); } } if (myTag == "Q" || parentTag == "Q") { PT_B_Quotation myModel = (PT_B_Quotation)t_pgg_Bill.SelectedItem; if (myModel.Bill_Status != "R") { MessageResult myResult = XMessageBox.Ask("确认删除当前选中的单据?", this); if (myResult == MessageResult.Yes) { myModel.Bill_Status = "R"; m_Entities.SaveChanges(); RefreshTreeNode(); } } else { MessageResult myResult = XMessageBox.Ask("确认彻底删除当前选中的单据?", this); if (myResult == MessageResult.Yes) { m_Entities.PT_B_Quotation.Remove(myModel); m_Entities.SaveChanges(); RefreshTreeNode(); } } } else { PT_B_Project myModel = (PT_B_Project)t_pgg_Bill.SelectedItem; if (myModel.Bill_Status != "R") { MessageResult myResult = XMessageBox.Ask("确认删除当前选中的单据?", this); if (myResult == MessageResult.Yes) { myModel.Bill_Status = "R"; m_Entities.SaveChanges(); RefreshTreeNode(); } } else { MessageResult myResult = XMessageBox.Ask("确认彻底删除当前选中的单据?", this); if (myResult == MessageResult.Yes) { m_Entities.PT_B_Project.Remove(myModel); m_Entities.SaveChanges(); RefreshTreeNode(); } } } } catch (Exception ex) { XMessageBox.Exception(ex); } }