protected void dgSupplier_ItemCommand(object source, DataGridCommandEventArgs e) { ChurchERP.CoreDomain.Setting.SoleVendorSupplier supplier = new ChurchERP.CoreDomain.Setting.SoleVendorSupplier(); if (e.CommandName == "AddNew") { try { DropDownList ddlSuppliertype = e.Item.FindControl("ddlSupplierType") as DropDownList; supplier.SupplierType = _presenter.GetSupplierTypeById(Convert.ToInt32(ddlSuppliertype.SelectedValue)); TextBox txtFSupplierName = e.Item.FindControl("txtFSupplierName") as TextBox; supplier.SupplierName = txtFSupplierName.Text; TextBox txtFSupplierAddress = e.Item.FindControl("txtFSupplierAddress") as TextBox; supplier.SupplierAddress = txtFSupplierAddress.Text; TextBox txtFSupplierContact = e.Item.FindControl("txtFSupplierContact") as TextBox; supplier.SupplierContact = txtFSupplierContact.Text; TextBox txtFSupplierphoneContact = e.Item.FindControl("txtFSupplierphoneContact") as TextBox; supplier.ContactPhone = txtFSupplierphoneContact.Text; TextBox txtFSupplierEmail = e.Item.FindControl("txtFSupplierEmail") as TextBox; supplier.Email = txtFSupplierEmail.Text; TextBox txtStartingDate = e.Item.FindControl("txtStartingDate") as TextBox; supplier.StartingDate = Convert.ToDateTime(txtStartingDate.Text); TextBox txtEndDate = e.Item.FindControl("txtEndDate") as TextBox; supplier.EndDate = Convert.ToDateTime(txtEndDate.Text); DropDownList ddlStatus = e.Item.FindControl("ddlFStatus") as DropDownList; supplier.Status = ddlStatus.SelectedValue; SaveSoleVendorSupplier(supplier); dgSupplier.EditItemIndex = -1; BindSoleVendorSupplier(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Add Supplier " + ex.Message, ChurchERP.Enums.RMessageType.Error)); } } }
protected void dgSupplier_DeleteCommand(object source, DataGridCommandEventArgs e) { int id = (int)dgSupplier.DataKeys[e.Item.ItemIndex]; ChurchERP.CoreDomain.Setting.SoleVendorSupplier SoleVendorSupplier = _presenter.GetSoleVendorSupplierById(id); try { SoleVendorSupplier.Status = "InActive"; _presenter.SaveOrUpdateSoleVendorSupplier(SoleVendorSupplier); BindSoleVendorSupplier(); Master.ShowMessage(new AppMessage("Supplier was Removed Successfully", ChurchERP.Enums.RMessageType.Info)); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to delete Supplier. " + ex.Message, ChurchERP.Enums.RMessageType.Error)); } }
private void SaveSoleVendorSupplier(ChurchERP.CoreDomain.Setting.SoleVendorSupplier Supplier) { try { if (Supplier.Id <= 0) { _presenter.SaveOrUpdateSoleVendorSupplier(Supplier); Master.ShowMessage(new AppMessage("Supplier saved", RMessageType.Info)); //_presenter.CancelPage(); } else { _presenter.SaveOrUpdateSoleVendorSupplier(Supplier); Master.ShowMessage(new AppMessage("Supplier Updated", RMessageType.Info)); // _presenter.CancelPage(); } } catch (Exception ex) { Master.ShowMessage(new AppMessage(ex.Message, RMessageType.Error)); } }