public async Task <ReturnedSaveFuncInfo> SaveAsync(NoteBussines item, SqlTransaction tr) { var res = new ReturnedSaveFuncInfo(); try { var cmd = new SqlCommand("sp_Note_Save", tr.Connection, tr) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@guid", item.Guid); cmd.Parameters.AddWithValue("@title", item.Title ?? ""); cmd.Parameters.AddWithValue("@desc", item.Description ?? ""); cmd.Parameters.AddWithValue("@dateSabt", item.DateSabt); cmd.Parameters.AddWithValue("@dateSarresid", item.DateSarresid); cmd.Parameters.AddWithValue("@userGuid", item.UserGuid); cmd.Parameters.AddWithValue("@priority", (short)item.Priority); cmd.Parameters.AddWithValue("@status", (short)item.NoteStatus); await cmd.ExecuteNonQueryAsync(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); res.AddReturnedValue(ex); } return(res); }
public frmNoteMain(Guid guid, bool isShowMode) { InitializeComponent(); cls = NoteBussines.Get(guid); grp.Enabled = !isShowMode; btnFinish.Enabled = !isShowMode; }
public async Task <NoteBussines> GetAsync(string _connectionString, Guid guid) { var obj = new NoteBussines(); try { using (var cn = new SqlConnection(_connectionString)) { var cmd = new SqlCommand("sp_Note_Get", cn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@guid", guid); await cn.OpenAsync(); var dr = await cmd.ExecuteReaderAsync(); if (dr.Read()) { obj = LoadData(dr); } cn.Close(); } } catch (Exception exception) { WebErrorLog.ErrorInstence.StartErrorLog(exception); } return(obj); }
private NoteBussines LoadData(SqlDataReader dr) { var item = new NoteBussines(); try { item.Guid = (Guid)dr["Guid"]; item.Title = dr["Title"].ToString(); item.Description = dr["Description"].ToString(); item.DateSabt = (DateTime)dr["DateSabt"]; if (dr["DateSarresid"] != DBNull.Value) { item.DateSarresid = (DateTime)dr["DateSarresid"]; } item.UserGuid = (Guid)dr["UserGuid"]; item.UserName = dr["UserName"].ToString(); item.Priority = (EnNotePriority)dr["Priority"]; item.NoteStatus = (EnNoteStatus)dr["NoteStatus"]; } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } return(item); }
private async Task RefreshLables() { try { var allBuilding = await BuildingBussines.DbCount(Guid.Empty, 0); var myBuilding = await BuildingBussines.DbCount(UserBussines.CurrentUser.Guid, 0); var rahn = await BuildingBussines.DbCount(Guid.Empty, 1); var foroush = await BuildingBussines.DbCount(Guid.Empty, 2); var allReq = await BuildingRequestBussines.DbCount(Guid.Empty); var myReq = await BuildingRequestBussines.DbCount(UserBussines.CurrentUser.Guid); var myCon = await ContractBussines.DbCount(UserBussines.CurrentUser.Guid); var disCharge = await ContractBussines.DischargeDbCount(); BirthdayList = await PeoplesBussines.GetAllBirthDayAsync(Calendar.MiladiToShamsi(DateTime.Now)); var minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); var maxDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59); allNote = await NoteBussines.GetAllAsync(); allNote = allNote.Where(q => q.DateSarresid != null && q.DateSarresid >= minDate && q.DateSarresid <= maxDate) .ToList(); Invoke(new MethodInvoker(() => { lblAllBiulding.Text = allBuilding.ToString(); lblMyBuilding.Text = myBuilding.ToString(); lblAllRahn.Text = rahn.ToString(); lblAllForoush.Text = foroush.ToString(); lblAllRequest.Text = allReq.ToString(); lblMyRequest.Text = myReq.ToString(); lblMyContract.Text = myCon.ToString(); lblBirthday.Text = BirthdayList.Count.ToString(); lblNotes.Text = allNote.Count.ToString(); //lblReceptionCheck.Text = receptionCheck.ToString(); //lblPardakhtCheck.Text = pardakhtCheck.ToString(); lblSarresidEjare.Text = disCharge.ToString(); btnBirthday.Enabled = BirthdayList.Count != 0; btnReminderNotes.Enabled = allNote.Count != 0; //btnReceptionCheck.Enabled = receptionCheck != 0; //btnPardakhtCheck.Enabled = pardakhtCheck != 0; btnDischarge.Enabled = disCharge != 0; })); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async void mnuDelete_Click(object sender, EventArgs e) { try { if (DGrid.RowCount <= 0) { return; } if (DGrid.CurrentRow == null) { return; } var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value; var note = await NoteBussines.GetAsync(guid); if (note == null) { return; } if (note.NoteStatus == EnNoteStatus.Deleted) { frmNotification.PublicInfo.ShowMessage("یادداشت انتخاب شده درحال حاظر در وضعیت حذف شده می باشد"); return; } if (MessageBox.Show( $@"آیا از اعمال تغییرات اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } note.NoteStatus = EnNoteStatus.Deleted; var res = await note.SaveAsync(); if (res.HasError) { frmNotification.PublicInfo.ShowMessage(res.ErrorMessage); return; } LoadData(txtSearch.Text); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private void LoadData(string search = "") { try { if (cmbUsers.SelectedValue == null) { return; } var list = NoteBussines.GetAll(search, (Guid)cmbUsers.SelectedValue, (EnNoteStatus)cmbStatus.SelectedIndex, (EnNotePriority)cmbPriority.SelectedIndex); noteBindingSource.DataSource = list.ToList(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public frmNoteMain() { InitializeComponent(); cls = new NoteBussines(); }
public frmNoteMain(Guid guid) { InitializeComponent(); cls = NoteBussines.Get(guid); }