private void AddClientAdd() { ClientAdd client = new ClientAdd(); ClientAddCollection.Add(client); SelectedClientAdd = client; MessageBox.Show("Click Save button after entering the new Client Address details.", "Client Location", MessageBoxButton.OK, MessageBoxImage.Warning); }
public ServiceResult Save() { List <string> lis = new List <string>(); lis.Add(SourceLiaoxinNumber); lis.Add(ToLiaoxinNumber); var source = Context.Clients.Where(c => lis.Contains(c.LiaoxinNumber)).Select(c => new { c.ClientId, c.LiaoxinNumber }).ToList(); var sourceClient = source.FirstOrDefault(c => c.LiaoxinNumber == SourceLiaoxinNumber); if (sourceClient == null) { return(new ServiceResult(ServiceResultCode.QueryNull, "没有找到源聊信号")); } var toClient = source.FirstOrDefault(c => c.LiaoxinNumber == ToLiaoxinNumber); if (toClient == null) { return(new ServiceResult(ServiceResultCode.QueryNull, "没有找到目标聊信号")); } var applySourceCnt = Context.ClientAdds.Where(c => c.ClientId == sourceClient.ClientId).Count(); var applyToCnt = Context.ClientAddDetails.Where(c => c.ClientId == toClient.ClientId && c.Status != ClientAddDetailTypeEnum.StandBy).Count(); if (applySourceCnt > 0 && applyToCnt > 0) { return(new ServiceResult(ServiceResultCode.Error, "你已申请添加此客户,无需要重复申请")); } var sourceCnt = Context.ClientRelations.Where(c => c.ClientId == sourceClient.ClientId && c.RelationType == ClientRelation.RelationTypeEnum.Friend).Count(); var toCnt = Context.ClientRelationDetails.Where(c => c.ClientId == toClient.ClientId).Count(); if (sourceCnt > 0 && toCnt > 0) { return(new ServiceResult(ServiceResultCode.Error, "你已添加此客户,无需要重复添加")); } ClientAdd clientAddEntity = new ClientAdd();; clientAddEntity.ClientId = sourceClient.ClientId; if (applySourceCnt == 0) { Context.ClientAdds.Add(clientAddEntity); } ClientAddDetail detailEntity = new ClientAddDetail() { ClientAddId = clientAddEntity.ClientAddId, AddRemark = Remark, ClientId = toClient.ClientId }; Context.ClientAddDetails.Add(detailEntity); UserOperateLogService.Log($"添加客户申请,源客户[{sourceClient.LiaoxinNumber}]申请添加客户[{toClient.LiaoxinNumber}]", Context); Context.SaveChanges(); return(new ServiceResult(ServiceResultCode.Success)); }
private void btnAdd_Click(object sender, EventArgs e) { ClientAdd f = new ClientAdd() { RefForm = (MainForm)this }; f.ShowDialog(); f.Dispose(); }
public ClientAddManagementViewModel(string ClientId) { //1. Its going to connect to DAL and bring in the results of all Instructors //2. we Create objects of type instructor and then add that object to our collection DAL dal = new DAL(); DataTable dt = dal.Read("Select * from bit_client_location where Client_Id=" + ClientId); PassedClientId = Convert.ToInt32(ClientId); // clientadd.UserID = UserId; foreach (DataRow dr in dt.Rows) { ClientAdd client = new ClientAdd(dr); ClientAddCollection.Add(client); } }