public override int?Save(string action) { var data = new ClientDataModel(); data.ClientId = SystemKeyId; data.Name = Name; data.Description = Description; data.SortOrder = SortOrder; if (action == "Insert") { var dtClient = ClientDataManager.DoesExist(data, SessionVariables.RequestProfile); if (dtClient.Rows.Count == 0) { ClientDataManager.Create(data, SessionVariables.RequestProfile); } else { throw new Exception("Record with given ID already exists."); } } else { ClientDataManager.Update(data, SessionVariables.RequestProfile); } // not correct ... when doing insert, we didn't get/change the value of ClientID ? return(data.ClientId); }
protected void btnUpdate_Click(object sender, EventArgs e) { var updatedData = new DataTable(); var data = new ClientDataModel(); updatedData = ClientDataManager.Search(data, SessionVariables.RequestProfile).Clone(); for (var i = 0; i < SelectedData.Rows.Count; i++) { data.ClientId = Convert.ToInt32(SelectedData.Rows[i][ClientDataModel.DataColumns.ClientId].ToString()); if (IsNameSelected) { data.Name = Name; } else { data.Name = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Name].ToString(); } if (IsDescriptionSelected) { data.Description = Description; } else { data.Description = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Description].ToString(); } if (IsSortOrderSelected) { data.SortOrder = SortOrder; } else { data.SortOrder = Convert.ToInt32(SelectedData.Rows[i][StandardDataModel.StandardDataColumns.SortOrder].ToString()); } ClientDataManager.Update(data, SessionVariables.RequestProfile); data = new ClientDataModel(); data.ClientId = Convert.ToInt32(SelectedData.Rows[i][ClientDataModel.DataColumns.ClientId].ToString()); var dt = ClientDataManager.Search(data, SessionVariables.RequestProfile); if (dt.Rows.Count == 1) { updatedData.ImportRow(dt.Rows[0]); } // if everything is done and good THEN move from thsi page. //Response.Redirect("Default.aspx?Added=" + true, false); } MainGridView.DataSource = updatedData; MainGridView.DataBind(); }
protected override void Update(Dictionary <string, string> values) { var data = new ClientDataModel(); // copies properties from values dictionary object to data object PropertyMapper.CopyProperties(data, values); ClientDataManager.Update(data, SessionVariables.RequestProfile); base.Update(values); }
private void UpdateData(ArrayList values) { var data = new ClientDataModel(); data.ClientId = int.Parse(values[0].ToString()); data.Name = values[1].ToString(); data.Description = values[2].ToString(); data.SortOrder = int.Parse(values[3].ToString()); ClientDataManager.Update(data, SessionVariables.RequestProfile); ReBindEditableGrid(); }
protected override DataTable UpdateData() { var UpdatedData = new DataTable(); var data = new ClientDataModel(); UpdatedData = ClientDataManager.Search(data, SessionVariables.RequestProfile).Clone(); for (var i = 0; i < SelectedData.Rows.Count; i++) { data.ClientId = Convert.ToInt32(SelectedData.Rows[i][ClientDataModel.DataColumns.ClientId].ToString()); data.Name = SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Name].ToString(); data.Description = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description)) ? CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.Description) : SelectedData.Rows[i][StandardDataModel.StandardDataColumns.Description].ToString(); data.SortOrder = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder)) ? int.Parse(CheckAndGetRepeaterTextBoxValue(StandardDataModel.StandardDataColumns.SortOrder)) : int.Parse(SelectedData.Rows[i][StandardDataModel.StandardDataColumns.SortOrder].ToString()); ClientDataManager.Update(data, SessionVariables.RequestProfile); data = new ClientDataModel(); data.ClientId = Convert.ToInt32(SelectedData.Rows[i][ClientDataModel.DataColumns.ClientId].ToString()); var dt = ClientDataManager.Search(data, SessionVariables.RequestProfile); if (dt.Rows.Count == 1) { UpdatedData.ImportRow(dt.Rows[0]); } } return(UpdatedData); }