public frmCustomerGroup(Guid guid, bool isShowMode) { InitializeComponent(); cls = CustomerGroupBussines.Get(guid); grpAccount.Enabled = !isShowMode; btnFinish.Enabled = !isShowMode; }
public static async Task InsertDefaultDataAsync() { var dbContext = new ModelContext(); var res = new ReturnedSaveFuncInfo(); #region Customer var allCusGroup = await CustomerGroupBussines.GetAllAsync(); if (allCusGroup.Count <= 0) { var cusGroup = new CustomerGroupBussines() { Guid = Guid.NewGuid(), Name = "فروشگاه اینترنتی", ParentGuid = Guid.Empty }; res.AddReturnedValue(await cusGroup.SaveAsync()); res.ThrowExceptionIfError(); } #endregion #region Rolles var allRolles = await RolleBussines.GetAllAsync(); var _roolesList = new List <RolleBussines>(); if (allRolles.Count <= 0) { var rolle1 = new RolleBussines() { Guid = Guid.NewGuid(), RolleName = "User", RolleTitle = "کاربر عادی" }; var rolle2 = new RolleBussines() { Guid = Guid.NewGuid(), RolleName = "Admin", RolleTitle = "مدیر کل سیستم" }; _roolesList.Add(rolle1); _roolesList.Add(rolle2); res.AddReturnedValue(await RolleBussines.SaveRangeAsync(_roolesList)); res.ThrowExceptionIfError(); } #endregion await dbContext.SaveChangesAsync(); dbContext.Dispose(); }
private async Task LoadGroup() { try { var list = await CustomerGroupBussines.GetAllAsync(); CusGroupBindingSource.DataSource = list.OrderBy(q => q.Name).ToList(); if (list.Count > 0) { cmbGroup.SelectedIndex = 0; } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async void btnFinish_Click(object sender, EventArgs e) { try { if (cls.Guid == Guid.Empty) { cls.Guid = Guid.NewGuid(); } if (string.IsNullOrEmpty(txtName.Text)) { frmNotification.PublicInfo.ShowMessage("عنوان گروه نمی تواند خالی باشد"); txtName.Focus(); return; } if (!await CustomerGroupBussines.CheckName(cls.Guid, txtName.Text.Trim())) { frmNotification.PublicInfo.ShowMessage("عنوان وارد شده تکراری است"); txtName.Focus(); return; } cls.Name = txtName.Text.Trim(); cls.Description = txtDesc.Text; cls.ParentGuid = (Guid)cmbParent.SelectedValue; var res = await cls.SaveAsync(); if (res.HasError) { frmNotification.PublicInfo.ShowMessage(res.ErrorMessage); return; } DialogResult = DialogResult.OK; frmLoading.PublicInfo.ShowForm(); Close(); } catch (Exception exception) { WebErrorLog.ErrorInstence.StartErrorLog(exception); } }
private async Task LoadData() { try { var a = new CustomerGroupBussines() { Guid = Guid.Empty, Name = "[هیچکدام]", ParentGuid = Guid.Empty, Description = "" }; var list = await CustomerGroupBussines.GetAllAsync(); list = list.Where(q => q.ParentGuid == Guid.Empty).ToList(); list.Add(a); ParentBindingSource.DataSource = list.OrderBy(q => q.Name).ToList(); } catch (Exception e) { WebErrorLog.ErrorInstence.StartErrorLog(e); } }
public frmCustomerGroup() { InitializeComponent(); cls = new CustomerGroupBussines(); }