private void BindTransportGrid() { hdnRouteID.Text = "0"; try { int index = 0; transportFeeSetting = new TransportFeeSetting(); List <TransportRouteModel> listTransport = transportFeeSetting.GetTransportRoute(); if (listTransport != null && listTransport.Count > 0) { gridTransport.DataSource = transportFeeSetting.GetTransportRoute(); foreach (TransportRouteModel list in listTransport) { DataGridViewTextBoxCell colRouteID = (DataGridViewTextBoxCell)(gridTransport.Rows[index].Cells["colRouteID"]); DataGridViewLinkCell colRouteName = (DataGridViewLinkCell)(gridTransport.Rows[index].Cells["colRouteName"]); DataGridViewTextBoxCell colAmount = (DataGridViewTextBoxCell)(gridTransport.Rows[index].Cells["colAmount"]); colRouteID.Value = list.RouteID; colRouteName.Value = list.RouteName; colAmount.Value = list.Amount; index++; } gridTransport.ClearSelection(); } } catch (Exception ex) { } }
private void btnSave_Click(object sender, EventArgs e) { try { if (ValidateControls()) { transportRouteModel = new TransportRouteModel { RouteID = Convert.ToInt32(hdnRouteID.Text) == 0 ? null : (int?)Convert.ToInt32(hdnRouteID.Text), RouteName = txtRouteName.Text.ToProper(), Amount = Convert.ToInt16(txtAmount.Text) }; transportFeeSetting = new TransportFeeSetting(); short result = transportFeeSetting.SaveTransportRoute(transportRouteModel); switch (result) { case 0: ShowMessageBox("Record Already Exists."); txtRouteName.Focus(); break; case 1: ShowMessageBox("Record Successfully Saved."); BindTransportGrid(); ClearControls(); break; case -1: ShowMessageBox("Error In Saving Details. Please Contact to Admin."); break; } } } catch (Exception ex) { ShowMessageBox("Error: Please contact to Admin."); } }