public static string InsertCollectionSpecialist(clsCollectionSpecialist data) { string errMsg = ""; PuroTouchSQLDataContext o = new PuroTouchSQLDataContext(); try { tblCollectionSpecialist oNewRow = new tblCollectionSpecialist() { email = data.email, idEmployee = data.idEmployee, CreatedBy = data.CreatedBy, CreatedOn = DateTime.Now, //UpdatedBy = data.UpdatedBy, //UpdatedOn = (DateTime?)data.UpdatedOn, ActiveFlag = data.ActiveFlag, ReceiveNewReqEmail = data.ReceiveNewReqEmail, login = data.login }; o.GetTable <tblCollectionSpecialist>().InsertOnSubmit(oNewRow); o.SubmitChanges(); } catch (Exception ex) { errMsg = ex.Message.ToString(); } return(errMsg); }
private clsCollectionSpecialist populateObj(UserControl userControl) { clsCollectionSpecialist oRow = new clsCollectionSpecialist(); oRow.email = (userControl.FindControl("txtEmail") as RadTextBox).Text; oRow.idEmployee = Convert.ToInt16((userControl.FindControl("rddlEmployee") as RadDropDownList).SelectedValue); oRow.Name = (userControl.FindControl("rddlEmployee") as RadDropDownList).SelectedText; oRow.ActiveFlag = (userControl.FindControl("ActiveFlag") as RadButton).Checked; oRow.ReceiveNewReqEmail = (userControl.FindControl("NewReqEmail") as RadButton).Checked; oRow.login = (userControl.FindControl("txtLogin") as RadTextBox).Text; oRow.CreatedBy = (string)(Session["userName"]); oRow.UpdatedOn = Convert.ToDateTime(DateTime.Now); oRow.UpdatedBy = (string)(Session["userName"]); oRow.UpdatedOn = Convert.ToDateTime(DateTime.Now); return(oRow); }
protected void rgITBA_UpdateCommand(object source, GridCommandEventArgs e) { try { UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); Label errorMsg = (Label)userControl.FindControl("lblErrorMessage"); clsCollectionSpecialist oRow = populateObj(userControl); oRow.idCollectionSpecialist = Convert.ToInt16((userControl.FindControl("hdnITBAID") as HiddenField).Value); string updateMsg = ""; if (IsValid) { if (oRow != null) { updateMsg = SrvCollectionSpecialist.UpdateCollectionSpecialist(oRow); if (updateMsg == "") { lblSuccess.Text = "Successfully updated information for " + "'" + oRow.Name + "'"; } else { errorMsg.Visible = true; errorMsg.Text = updateMsg; e.Canceled = true; } } } else { 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 rgITBA_InsertCommand(object sender, GridCommandEventArgs e) { try { UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); Label errorMsg = (Label)userControl.FindControl("lblErrorMessage"); clsCollectionSpecialist oRow = populateObj(userControl); string insertMsg = ""; if (IsValid) { if (oRow != null) { insertMsg = SrvCollectionSpecialist.InsertCollectionSpecialist(oRow); if (insertMsg == "") { lblSuccess.Text = "Successfully Added New Record " + oRow.Name; } else { errorMsg.Visible = true; errorMsg.Text = insertMsg; e.Canceled = true; } } } else { 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 static string UpdateCollectionSpecialist(clsCollectionSpecialist data) { string errMsg = ""; PuroTouchSQLDataContext o = new PuroTouchSQLDataContext(); try { if (data.idEmployee > 0) { var query = from qdata in o.GetTable <tblCollectionSpecialist>() where qdata.idEmployee == data.idEmployee select qdata; foreach (tblCollectionSpecialist updRow in query) { updRow.email = data.email; updRow.idEmployee = data.idEmployee; updRow.ActiveFlag = data.ActiveFlag; updRow.UpdatedBy = data.UpdatedBy; updRow.UpdatedOn = DateTime.Now; updRow.ReceiveNewReqEmail = data.ReceiveNewReqEmail; updRow.login = data.login; } // Submit the changes to the database. o.SubmitChanges(); } else { errMsg = "There is No Shipping Product with ID = " + "'" + data.idEmployee + "'"; } } catch (Exception ex) { errMsg = ex.Message.ToString(); } return(errMsg); }