public string UpdateInductionPoint(ClsInductionPoint data) { string errMsg = ""; PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext(); try { if (data.idInduction > 0) { // Query the database for the row to be updated. var query = from qdata in puroTouchContext.GetTable <tblInductionPoint>() where qdata.idInduction == data.idInduction select qdata; // Execute the query, and change the column values // you want to change. foreach (tblInductionPoint updRow in query) { updRow.Description = data.Description; updRow.Address = data.Address; updRow.City = data.City; updRow.State = data.State; updRow.Zip = data.Zip; updRow.Country = data.Country; updRow.ActiveFlag = data.ActiveFlag; updRow.PuroPostFlag = data.PuroPostFlag; updRow.idInduction = data.idInduction; updRow.UpdatedBy = data.UpdatedBy; updRow.UpdatedOn = data.UpdatedOn; } // Submit the changes to the database. puroTouchContext.SubmitChanges(); } else { errMsg = "There is No Induction Point with ID = " + "'" + data.idInduction + "'"; } } catch (Exception ex) { errMsg = ex.Message.ToString(); } return(errMsg); }
private ClsInductionPoint populateObj(UserControl userControl) { ClsInductionPoint oRow = new ClsInductionPoint(); oRow.Description = (userControl.FindControl("txtDescription") as RadTextBox).Text; oRow.Address = (userControl.FindControl("txtAddress") as RadTextBox).Text; oRow.City = (userControl.FindControl("txtCity") as RadTextBox).Text; oRow.State = (userControl.FindControl("txtState") as RadTextBox).Text; oRow.Zip = (userControl.FindControl("txtZip") as RadTextBox).Text; oRow.Country = (userControl.FindControl("txtCountry") as RadTextBox).Text; oRow.ActiveFlag = (userControl.FindControl("ActiveFlag") as RadButton).Checked; oRow.PuroPostFlag = (userControl.FindControl("PuroPostFlag") as RadButton).Checked; oRow.UpdatedBy = (string)(Session["userName"]); oRow.UpdatedOn = Convert.ToDateTime(DateTime.Now); return(oRow); }
protected void rgGrid_UpdateCommand(object sender, GridCommandEventArgs e) { try { UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); Label errorMsg = (Label)userControl.FindControl("lblErrorMessage"); ClsInductionPoint oRow = populateObj(userControl); oRow.idInduction = Convert.ToInt16((userControl.FindControl("idInduction") as Label).Text); string updateMsg = ""; if (IsValid) { if (oRow != null) { updateMsg = cls.UpdateInductionPoint(oRow); if (updateMsg == "") { pnlsuccess.Visible = true; lblSuccess.Text = "Successfully updated information for " + "'" + oRow.Description + "'"; } else { errorMsg.Visible = true; errorMsg.Text = updateMsg; e.Canceled = true; } } } else { // display error errorMsg.Visible = true; errorMsg.Text = "Please enter Required fields"; e.Canceled = true; } } catch (Exception ex) { pnlDanger.Visible = true; lblDanger.Text = ex.Message.ToString(); e.Canceled = true; } }
protected void rgGrid_InsertCommand(object sender, GridCommandEventArgs e) { try { UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); Label errorMsg = (Label)userControl.FindControl("lblErrorMessage"); ClsInductionPoint oRow = populateObj(userControl); string insertMsg = ""; if (IsValid) { if (oRow != null) { insertMsg = cls.InsertInductionPoint(oRow); if (insertMsg == "") { pnlsuccess.Visible = true; lblSuccess.Text = "Successfully Added New Record " + oRow.Description; } else { errorMsg.Visible = true; errorMsg.Text = insertMsg; e.Canceled = true; } } } else { // display error errorMsg.Visible = true; errorMsg.Text = "Please enter Required fields"; e.Canceled = true; } } catch (Exception ex) { pnlDanger.Visible = true; lblDanger.Text = ex.Message.ToString(); e.Canceled = true; } }
public string InsertInductionPoint(ClsInductionPoint data) { string errMsg = ""; PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext(); try { tblInductionPoint oNewRow = new tblInductionPoint() { Description = data.Description, Address = data.Address, City = data.City, State = data.State, Zip = data.Zip, Country = data.Country, CreatedBy = data.CreatedBy, CreatedOn = (DateTime?)data.CreatedOn, //UpdatedBy = data.UpdatedBy, //UpdatedOn = (DateTime?)data.UpdatedOn, ActiveFlag = data.ActiveFlag, PuroPostFlag = data.PuroPostFlag }; puroTouchContext.GetTable <tblInductionPoint>().InsertOnSubmit(oNewRow); // Submit the changes to the database. puroTouchContext.SubmitChanges(); //newID = oNewRow.idTaskType; } catch (Exception ex) { errMsg = ex.Message.ToString(); } return(errMsg); }