private async void mnuEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0 || DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid   = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var tafsil = await AdjectiveDescriptionBussines.GetAsync(guid);

                if (tafsil == null)
                {
                    frmNotification.PublicInfo.ShowMessage("شرح انتخاب شده معتبر نمی باشد");
                    return;
                }

                var frm = new frmDescMain(guid);
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemple #2
0
        public async Task <AdjectiveDescriptionBussines> GetAsync(string connectionString, Guid guid)
        {
            AdjectiveDescriptionBussines res = null;

            try
            {
                using (var cn = new SqlConnection(connectionString))
                {
                    var cmd = new SqlCommand("sp_Desc_Get", cn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("@guid", guid);

                    await cn.OpenAsync();

                    var dr = await cmd.ExecuteReaderAsync();

                    if (dr.Read())
                    {
                        res = LoadData(dr);
                    }
                    dr.Close();
                    cn.Close();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(res);
        }
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                var list = await AdjectiveDescriptionBussines.GetAllAsync(search);

                Invoke(new MethodInvoker(() => DescBindingSource.DataSource = list.ToSortableBindingList()));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Exemple #4
0
        private AdjectiveDescriptionBussines LoadData(SqlDataReader dr)
        {
            var item = new AdjectiveDescriptionBussines();

            try
            {
                item.Guid        = (Guid)dr["Guid"];
                item.Description = dr["Description"].ToString();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
            return(item);
        }
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0 || DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid   = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var hazine = await AdjectiveDescriptionBussines.GetAsync(guid);

                if (hazine == null)
                {
                    return;
                }

                if (MessageBox.Show(this,
                                    $@"آیا از حذف  شرح آماده اطمینان دارید؟", "حذف",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
                res.AddReturnedValue(await hazine.RemoveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (!res.HasError)
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Exemple #6
0
        public async Task <ReturnedSaveFuncInfo> SaveAsync(AdjectiveDescriptionBussines item, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_Desc_Save", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@guid", item.Guid);
                cmd.Parameters.AddWithValue("@desc", item.Description ?? "");

                await cmd.ExecuteNonQueryAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Exemple #7
0
 public frmDescMain(Guid guid)
 {
     InitializeComponent();
     cls = AdjectiveDescriptionBussines.Get(guid);
 }
Exemple #8
0
 public frmDescMain()
 {
     InitializeComponent();
     cls = new AdjectiveDescriptionBussines();
 }