/// <summary> /// this method is to get list of selected van(s) in the grid. /// </summary> /// <returns></returns> private EVan[] GetSelectedVan() { var ListVan = new ArrayList(); for (int i = 0; i < grdVanDetails.Rows.Count; i++) { var chkStateSelecter = new HtmlInputCheckBox(); chkStateSelecter = (HtmlInputCheckBox)grdVanDetails.Rows[i].FindControl("chkRowChild"); if (chkStateSelecter.Checked == true) { EVan van = new EVan(); van.VanID = Convert.ToInt32(((DataTable)(ViewState["DSGRID"])).Rows[grdVanDetails.Rows[i].DataItemIndex]["VanID"]); ListVan.Add(van); } } EVan[] Vans = new EVan[ListVan.Count]; for (int i = 0; i < ListVan.Count; i++) { Vans[i] = new EVan(); Vans[i] = (EVan)ListVan[i]; } return(Vans); }
/// <summary> /// this method is used for adding new and updating the information regarding the van which is /// called on clicking save button. /// </summary> private void UpdateVan() { var masterDal = new MasterDAL(); var van = new EVan { Description = txtDescription.Text, Name = txtName.Text, VIN = txtVIN.Text, Make = txtMake.Text, RegistrationNumber = txtReg.Text, Active = true }; var state = new EState { StateID = Convert.ToInt32(ddlstate.SelectedValue) }; van.State = state; Int64 returnresult; if (hfVanID.Value.Equals("")) { returnresult = masterDal.SaveVan(van, Convert.ToInt32(EOperationMode.Insert)); divErrorMsg.Visible = true; if (returnresult == 999998) { divErrorMsg.InnerText = "Name already exists"; } else if (returnresult == -5) { divErrorMsg.InnerText = "Van with same registration number exists"; } else { divErrorMsg.InnerText = "You have added a Van, please use the search at the top to retrieve the recently added van"; } } else { van.VanID = Convert.ToInt32(((DataTable)(ViewState["DSGRID"])).Rows[grdVanDetails.Rows[Convert.ToInt32(hfVanID.Value)].DataItemIndex]["VanID"]); masterDal.SaveVan(van, Convert.ToInt32(EOperationMode.Update)); divErrorMsg.Visible = true; divErrorMsg.InnerText = "Van details has been updated."; } hfVanID.Value = ""; GetVan(); }