public int InsertModel(ModelBase model) { if (model == null) { return(0); } lock (s_ServiceLocker) { ModelMapping mp = new ModelMapping(model.GetType()); Exception ex = null; int rid = ModelFactoryCollection.InsertModelReturnRid(model, mp, out ex); if (ex == null) { ModelAccessManager.CacheManager.Save(model); ExcuteAction action = new ExcuteAction(); action.ExcuteObject = model; model.Rid = rid; action.ExcuteType = ExcuteType.Insert; SendAll(action); } else { m_callback.ErrorNotify(this.ToString(), ex.Message, ExcuteType.Insert); } return(rid); } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("请输入部门名称"); return; } if (m_Department == null) { MessageBox.Show("请选择需要修改的对象"); return; } foreach (Department dept in ModelCacheManager.Instance[typeof(Department)]) { if (dept.Name == txtName.Text && dept.Rid != m_Department.Rid) { MessageBox.Show("部门名已被占用,请重新添加"); return; } } m_Department.Name = txtName.Text; m_Department.Remark = txtRemark.Text; ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Update; action.ExcuteObject = m_Department; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
private void btnDel_Click(object sender, RoutedEventArgs e) { if (m_Product == null) { MessageBox.Show("请选择需要删除的对象"); return; } ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Delete; action.ExcuteObject = m_Product; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); foreach (TraceInfo info in ModelCacheManager.Instance[typeof(TraceInfo)]) { if (info.Product == m_Product.Rid) { ExcuteAction act = new ExcuteAction(); act.ExcuteType = ExcuteType.Delete; act.ExcuteObject = info; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); } } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("请输入部门名称"); return; } foreach (Department dept in ModelCacheManager.Instance[typeof(Department)]) { if (txtName.Text == dept.Name) { MessageBox.Show("部门名已被占用,请重新添加"); return; } } Department newModel = new Department(); newModel.Name = txtName.Text; newModel.Remark = txtRemark.Text; ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Insert; action.ExcuteObject = newModel; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
private void btnUpd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("请输入产品名称"); return; } if (cmbPruductType.SelectedIndex == -1) { MessageBox.Show("请选择产品类别"); } TraceClientProxy.Instance.Proxy.DeleteFileAsync(m_Product.UserInfo.ToString(), m_Product.Name.ToString()); m_Product.Name = txtName.Text; m_Product.ProductType = Convert.ToInt32(cmbPruductType.SelectedValue); m_Product.UserInfo = TraceClientProxy.Instance.UserRid; TraceClientProxy.Instance.Proxy.SaveQRCodeAsync(m_Product.UserInfo.ToString(), m_Product.Name.ToString()); ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Update; action.ExcuteObject = m_Product; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (cmbUserType.SelectedIndex == -1) { MessageBox.Show("选择用户类型"); return; } if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("请输入用户名"); return; } foreach (UserInfo usr in ModelCacheManager.Instance[typeof(UserInfo)]) { if (usr.UserName == txtName.Text) { MessageBox.Show("已存在用户名"); return; } } m_UserInfo = new UserInfo(); m_UserInfo.UserName = txtName.Text; m_UserInfo.UserType = Convert.ToInt32(cmbUserType.SelectedValue); m_UserInfo.PassWord = "******"; m_UserInfo.Remark = ""; ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Insert; action.ExcuteObject = m_UserInfo; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
private void btnUpd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("请输入产品分类名称"); return; } foreach (ProductType p in ModelCacheManager.Instance[typeof(ProductType)]) { if (p.Name == txtName.Text && p.Rid != m_ProductType.Rid) { MessageBox.Show("类型名称已重复"); return; } } m_ProductType.Name = txtName.Text; ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Insert; action.ExcuteObject = m_ProductType; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
private void btnDel_Click(object sender, RoutedEventArgs e) { if (m_Department == null) { MessageBox.Show("请选择需要删除的对象"); return; } ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Delete; action.ExcuteObject = m_Department; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
private void btnDel_Click(object sender, RoutedEventArgs e) { if (m_TraceInfo == null) { MessageBox.Show("请选择需要删除的对象"); return; } ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Delete; action.ExcuteObject = m_TraceInfo; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); TraceClientProxy.Instance.Proxy.DeleteFileAsync(m_Product.UserInfo.ToString() + "//Trace", m_TraceInfo.Name); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("请输入追溯名称"); return; } foreach (TraceInfo info in ModelCacheManager.Instance[typeof(TraceInfo)]) { if (info.Name == txtName.Text) { MessageBox.Show("该名称已存在"); return; } } if (string.IsNullOrWhiteSpace(txtPicPath.Text)) { MessageBox.Show("请上传图片"); return; } m_TraceInfo = new TraceInfo(); m_TraceInfo.Name = txtName.Text; m_TraceInfo.Product = m_Product.Rid; m_TraceInfo.DateTime = DateTime.Now; m_TraceInfo.TextInfo = txtInfo.Text; m_TraceInfo.PicInfo = ""; TraceClientProxy.Instance.Proxy.UploadTextFileAsync(m_Product.UserInfo.ToString() + "//Trace", m_TraceInfo.Name, PicByte); ExcuteAction action = new ExcuteAction(); action.ExcuteType = ExcuteType.Insert; action.ExcuteObject = m_TraceInfo; TraceClientProxy.Instance.Proxy.ExcuteAsync(new ObservableCollection <ExcuteAction>() { action }); }
/// <summary> /// Define a method to be called when command is invoked /// </summary> /// <param name="parameter">This parameter will be always triggered</param> public override void Execute(object parameter) => ExcuteAction?.Invoke();
/// <summary> /// Define a method to be called when command is triggered /// </summary> /// <param name="parameter">Para</param> public override void Execute(object parameter) => ExcuteAction?.Invoke((T)Convert.ChangeType(parameter, typeof(T)));