private void UpdateRecord() { dbo_FactSalesQuotaClass oclsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); oclsdbo_FactSalesQuota.SalesQuotaKey = System.Convert.ToInt32(Session["SalesQuotaKey"]); oclsdbo_FactSalesQuota = dbo_FactSalesQuotaDataClass.Select_Record(oclsdbo_FactSalesQuota); if (VerifyData() == true) { SetData(clsdbo_FactSalesQuota); bool bSucess = false; bSucess = dbo_FactSalesQuotaDataClass.Update(oclsdbo_FactSalesQuota, clsdbo_FactSalesQuota); if (bSucess == true) { pnlForm.Visible = false; pnlSave.Visible = false; pnlGrid.Visible = true; lblMode.InnerText = ""; Session.Remove("dvdbo_FactSalesQuota"); LoadGriddbo_FactSalesQuota(); } else { ec.ShowMessage(" Update failed. ", " Dbo. Fact Sales Quota "); } } }
private void GetData() { ClearRecord(); dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); clsdbo_FactSalesQuota.SalesQuotaKey = System.Convert.ToInt32(Session["SalesQuotaKey"]); clsdbo_FactSalesQuota = dbo_FactSalesQuotaDataClass.Select_Record(clsdbo_FactSalesQuota); if ((clsdbo_FactSalesQuota != null)) { try { txtSalesQuotaKey.Text = System.Convert.ToString(clsdbo_FactSalesQuota.SalesQuotaKey); txtEmployeeKey.SelectedValue = System.Convert.ToString(clsdbo_FactSalesQuota.EmployeeKey); txtDateKey.SelectedValue = System.Convert.ToString(clsdbo_FactSalesQuota.DateKey); txtCalendarYear.Text = System.Convert.ToString(clsdbo_FactSalesQuota.CalendarYear); txtCalendarQuarter.Text = System.Convert.ToString(clsdbo_FactSalesQuota.CalendarQuarter); txtSalesAmountQuota.Text = System.Convert.ToString(clsdbo_FactSalesQuota.SalesAmountQuota); if (clsdbo_FactSalesQuota.Date == null) { txtDate.Text = DateTime.Now.ToString(); } else { txtDate.Text = System.Convert.ToDateTime(clsdbo_FactSalesQuota.Date).ToShortDateString(); } } catch (Exception ex) { ec.ShowMessage(ex.Message, " Dbo. Fact Sales Quota "); } } }
public static bool Delete(dbo_FactSalesQuotaClass clsdbo_FactSalesQuota) { SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection(); string deleteStatement = "DELETE FROM " + " [dbo].[FactSalesQuota] " + "WHERE " + " [SalesQuotaKey] = @OldSalesQuotaKey " + " AND [EmployeeKey] = @OldEmployeeKey " + " AND [DateKey] = @OldDateKey " + " AND [CalendarYear] = @OldCalendarYear " + " AND [CalendarQuarter] = @OldCalendarQuarter " + " AND [SalesAmountQuota] = @OldSalesAmountQuota " + " AND ((@OldDate IS NULL AND [Date] IS NULL) OR [Date] = @OldDate) " + ""; SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection); deleteCommand.CommandType = CommandType.Text; deleteCommand.Parameters.AddWithValue("@OldSalesQuotaKey", clsdbo_FactSalesQuota.SalesQuotaKey); deleteCommand.Parameters.AddWithValue("@OldEmployeeKey", clsdbo_FactSalesQuota.EmployeeKey); deleteCommand.Parameters.AddWithValue("@OldDateKey", clsdbo_FactSalesQuota.DateKey); deleteCommand.Parameters.AddWithValue("@OldCalendarYear", clsdbo_FactSalesQuota.CalendarYear); deleteCommand.Parameters.AddWithValue("@OldCalendarQuarter", clsdbo_FactSalesQuota.CalendarQuarter); deleteCommand.Parameters.AddWithValue("@OldSalesAmountQuota", clsdbo_FactSalesQuota.SalesAmountQuota); if (clsdbo_FactSalesQuota.Date.HasValue == true) { deleteCommand.Parameters.AddWithValue("@OldDate", clsdbo_FactSalesQuota.Date); } else { deleteCommand.Parameters.AddWithValue("@OldDate", DBNull.Value); } try { connection.Open(); int count = deleteCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }
public static dbo_FactSalesQuotaClass Select_Record(dbo_FactSalesQuotaClass clsdbo_FactSalesQuotaPara) { dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection(); string selectStatement = "SELECT " + " [SalesQuotaKey] " + " ,[EmployeeKey] " + " ,[DateKey] " + " ,[CalendarYear] " + " ,[CalendarQuarter] " + " ,[SalesAmountQuota] " + " ,[Date] " + "FROM " + " [dbo].[FactSalesQuota] " + "WHERE " + " [SalesQuotaKey] = @SalesQuotaKey " + ""; SqlCommand selectCommand = new SqlCommand(selectStatement, connection); selectCommand.CommandType = CommandType.Text; selectCommand.Parameters.AddWithValue("@SalesQuotaKey", clsdbo_FactSalesQuotaPara.SalesQuotaKey); try { connection.Open(); SqlDataReader reader = selectCommand.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { clsdbo_FactSalesQuota.SalesQuotaKey = System.Convert.ToInt32(reader["SalesQuotaKey"]); clsdbo_FactSalesQuota.EmployeeKey = System.Convert.ToInt32(reader["EmployeeKey"]); clsdbo_FactSalesQuota.DateKey = System.Convert.ToInt32(reader["DateKey"]); clsdbo_FactSalesQuota.CalendarYear = System.Convert.ToInt16(reader["CalendarYear"]); clsdbo_FactSalesQuota.CalendarQuarter = System.Convert.ToByte(reader["CalendarQuarter"]); clsdbo_FactSalesQuota.SalesAmountQuota = System.Convert.ToDecimal(reader["SalesAmountQuota"]); clsdbo_FactSalesQuota.Date = reader["Date"] is DBNull ? null : (DateTime?)reader["Date"]; } else { clsdbo_FactSalesQuota = null; } reader.Close(); } catch (SqlException) { return(clsdbo_FactSalesQuota); } finally { connection.Close(); } return(clsdbo_FactSalesQuota); }
private void Edit() { try { dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); Label lblSalesQuotaKey = (Label)grddbo_FactSalesQuota.Rows[grddbo_FactSalesQuota.EditIndex].FindControl("lblSalesQuotaKey"); clsdbo_FactSalesQuota.SalesQuotaKey = System.Convert.ToInt32(lblSalesQuotaKey.Text); clsdbo_FactSalesQuota = dbo_FactSalesQuotaDataClass.Select_Record(clsdbo_FactSalesQuota); Session["EmployeeKey_SelectedValue"] = clsdbo_FactSalesQuota.EmployeeKey; Session["DateKey_SelectedValue"] = clsdbo_FactSalesQuota.DateKey; LoadGriddbo_FactSalesQuota(); } catch { } }
private void SetData(dbo_FactSalesQuotaClass clsdbo_FactSalesQuota) { clsdbo_FactSalesQuota.EmployeeKey = System.Convert.ToInt32(txtEmployeeKey.SelectedValue); clsdbo_FactSalesQuota.DateKey = System.Convert.ToInt32(txtDateKey.SelectedValue); clsdbo_FactSalesQuota.CalendarYear = System.Convert.ToInt16(txtCalendarYear.Text); clsdbo_FactSalesQuota.CalendarQuarter = System.Convert.ToByte(txtCalendarQuarter.Text); clsdbo_FactSalesQuota.SalesAmountQuota = System.Convert.ToDecimal(txtSalesAmountQuota.Text); if (string.IsNullOrEmpty(txtDate.Text)) { clsdbo_FactSalesQuota.Date = null; } else { clsdbo_FactSalesQuota.Date = System.Convert.ToDateTime(txtDate.Text); } }
private void UpdateRecord() { try { TextBox txtSalesQuotaKey = (TextBox)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtSalesQuotaKey"); DropDownList txtEmployeeKey = (DropDownList)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtEmployeeKey"); DropDownList txtDateKey = (DropDownList)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtDateKey"); TextBox txtCalendarYear = (TextBox)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCalendarYear"); TextBox txtCalendarQuarter = (TextBox)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtCalendarQuarter"); TextBox txtSalesAmountQuota = (TextBox)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtSalesAmountQuota"); TextBox txtDate = (TextBox)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("txtDate"); dbo_FactSalesQuotaClass oclsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); oclsdbo_FactSalesQuota.SalesQuotaKey = System.Convert.ToInt32(txtSalesQuotaKey.Text); oclsdbo_FactSalesQuota = dbo_FactSalesQuotaDataClass.Select_Record(oclsdbo_FactSalesQuota); if (VerifyData() == true) { clsdbo_FactSalesQuota.EmployeeKey = System.Convert.ToInt32(txtEmployeeKey.SelectedValue); clsdbo_FactSalesQuota.DateKey = System.Convert.ToInt32(txtDateKey.SelectedValue); clsdbo_FactSalesQuota.CalendarYear = System.Convert.ToInt16(txtCalendarYear.Text); clsdbo_FactSalesQuota.CalendarQuarter = System.Convert.ToByte(txtCalendarQuarter.Text); clsdbo_FactSalesQuota.SalesAmountQuota = System.Convert.ToDecimal(txtSalesAmountQuota.Text); if (string.IsNullOrEmpty(txtDate.Text)) { clsdbo_FactSalesQuota.Date = null; } else { clsdbo_FactSalesQuota.Date = System.Convert.ToDateTime(txtDate.Text); } bool bSucess = false; bSucess = dbo_FactSalesQuotaDataClass.Update(oclsdbo_FactSalesQuota, clsdbo_FactSalesQuota); if (bSucess == true) { Session.Remove("dvdbo_FactSalesQuota"); grddbo_FactSalesQuota.EditIndex = -1; LoadGriddbo_FactSalesQuota(); } else { ec.ShowMessage(" Update failed. ", " Dbo. Fact Sales Quota "); } } } catch { } }
private void DeleteRecord() { dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); Label lblSalesQuotaKey = (Label)grddbo_FactSalesQuota.Rows[Convert.ToInt32(Session["Row"])].FindControl("lblSalesQuotaKey"); clsdbo_FactSalesQuota.SalesQuotaKey = System.Convert.ToInt32(lblSalesQuotaKey.Text); clsdbo_FactSalesQuota = dbo_FactSalesQuotaDataClass.Select_Record(clsdbo_FactSalesQuota); bool bSucess = false; bSucess = dbo_FactSalesQuotaDataClass.Delete(clsdbo_FactSalesQuota); if (bSucess == true) { Session.Remove("dvdbo_FactSalesQuota"); LoadGriddbo_FactSalesQuota(); } else { ec.ShowMessage(" Delete failed. ", " Dbo. Fact Sales Quota "); } }
private void InsertRecord() { try { DropDownList txtNewEmployeeKey = (DropDownList)grddbo_FactSalesQuota.FooterRow.FindControl("txtNewEmployeeKey"); DropDownList txtNewDateKey = (DropDownList)grddbo_FactSalesQuota.FooterRow.FindControl("txtNewDateKey"); TextBox txtNewCalendarYear = (TextBox)grddbo_FactSalesQuota.FooterRow.FindControl("txtNewCalendarYear"); TextBox txtNewCalendarQuarter = (TextBox)grddbo_FactSalesQuota.FooterRow.FindControl("txtNewCalendarQuarter"); TextBox txtNewSalesAmountQuota = (TextBox)grddbo_FactSalesQuota.FooterRow.FindControl("txtNewSalesAmountQuota"); TextBox txtNewDate = (TextBox)grddbo_FactSalesQuota.FooterRow.FindControl("txtNewDate"); dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); if (VerifyDataNew() == true) { clsdbo_FactSalesQuota.EmployeeKey = System.Convert.ToInt32(txtNewEmployeeKey.SelectedValue); clsdbo_FactSalesQuota.DateKey = System.Convert.ToInt32(txtNewDateKey.SelectedValue); clsdbo_FactSalesQuota.CalendarYear = System.Convert.ToInt16(txtNewCalendarYear.Text); clsdbo_FactSalesQuota.CalendarQuarter = System.Convert.ToByte(txtNewCalendarQuarter.Text); clsdbo_FactSalesQuota.SalesAmountQuota = System.Convert.ToDecimal(txtNewSalesAmountQuota.Text); if (string.IsNullOrEmpty(txtNewDate.Text)) { clsdbo_FactSalesQuota.Date = null; } else { clsdbo_FactSalesQuota.Date = System.Convert.ToDateTime(txtNewDate.Text); } bool bSucess = false; bSucess = dbo_FactSalesQuotaDataClass.Add(clsdbo_FactSalesQuota); if (bSucess == true) { Session.Remove("dvdbo_FactSalesQuota"); LoadGriddbo_FactSalesQuota(); } else { ec.ShowMessage(" Insert failed. ", " Dbo. Fact Sales Quota "); } } } catch { } }
private void InsertRecord() { dbo_FactSalesQuotaClass clsdbo_FactSalesQuota = new dbo_FactSalesQuotaClass(); if (VerifyData() == true) { SetData(clsdbo_FactSalesQuota); bool bSucess = false; bSucess = dbo_FactSalesQuotaDataClass.Add(clsdbo_FactSalesQuota); if (bSucess == true) { pnlForm.Visible = false; pnlSave.Visible = false; pnlGrid.Visible = true; lblMode.InnerText = ""; Session.Remove("dvdbo_FactSalesQuota"); LoadGriddbo_FactSalesQuota(); } else { ec.ShowMessage(" Insert failed. ", " Dbo. Fact Sales Quota "); } } }
public static bool Update(dbo_FactSalesQuotaClass olddbo_FactSalesQuotaClass, dbo_FactSalesQuotaClass newdbo_FactSalesQuotaClass) { SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection(); string updateStatement = "UPDATE " + " [dbo].[FactSalesQuota] " + "SET " + " [EmployeeKey] = @NewEmployeeKey " + " ,[DateKey] = @NewDateKey " + " ,[CalendarYear] = @NewCalendarYear " + " ,[CalendarQuarter] = @NewCalendarQuarter " + " ,[SalesAmountQuota] = @NewSalesAmountQuota " + " ,[Date] = @NewDate " + "WHERE " + " [SalesQuotaKey] = @OldSalesQuotaKey " + " AND [EmployeeKey] = @OldEmployeeKey " + " AND [DateKey] = @OldDateKey " + " AND [CalendarYear] = @OldCalendarYear " + " AND [CalendarQuarter] = @OldCalendarQuarter " + " AND [SalesAmountQuota] = @OldSalesAmountQuota " + " AND ((@OldDate IS NULL AND [Date] IS NULL) OR [Date] = @OldDate) " + ""; SqlCommand updateCommand = new SqlCommand(updateStatement, connection); updateCommand.CommandType = CommandType.Text; updateCommand.Parameters.AddWithValue("@NewEmployeeKey", newdbo_FactSalesQuotaClass.EmployeeKey); updateCommand.Parameters.AddWithValue("@NewDateKey", newdbo_FactSalesQuotaClass.DateKey); updateCommand.Parameters.AddWithValue("@NewCalendarYear", newdbo_FactSalesQuotaClass.CalendarYear); updateCommand.Parameters.AddWithValue("@NewCalendarQuarter", newdbo_FactSalesQuotaClass.CalendarQuarter); updateCommand.Parameters.AddWithValue("@NewSalesAmountQuota", newdbo_FactSalesQuotaClass.SalesAmountQuota); if (newdbo_FactSalesQuotaClass.Date.HasValue == true) { updateCommand.Parameters.AddWithValue("@NewDate", newdbo_FactSalesQuotaClass.Date); } else { updateCommand.Parameters.AddWithValue("@NewDate", DBNull.Value); } updateCommand.Parameters.AddWithValue("@OldSalesQuotaKey", olddbo_FactSalesQuotaClass.SalesQuotaKey); updateCommand.Parameters.AddWithValue("@OldEmployeeKey", olddbo_FactSalesQuotaClass.EmployeeKey); updateCommand.Parameters.AddWithValue("@OldDateKey", olddbo_FactSalesQuotaClass.DateKey); updateCommand.Parameters.AddWithValue("@OldCalendarYear", olddbo_FactSalesQuotaClass.CalendarYear); updateCommand.Parameters.AddWithValue("@OldCalendarQuarter", olddbo_FactSalesQuotaClass.CalendarQuarter); updateCommand.Parameters.AddWithValue("@OldSalesAmountQuota", olddbo_FactSalesQuotaClass.SalesAmountQuota); if (olddbo_FactSalesQuotaClass.Date.HasValue == true) { updateCommand.Parameters.AddWithValue("@OldDate", olddbo_FactSalesQuotaClass.Date); } else { updateCommand.Parameters.AddWithValue("@OldDate", DBNull.Value); } try { connection.Open(); int count = updateCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }
public static bool Add(dbo_FactSalesQuotaClass clsdbo_FactSalesQuota) { SqlConnection connection = AdventureWorksDW2012DataClass.GetConnection(); string insertStatement = "INSERT " + " [dbo].[FactSalesQuota] " + " ( " + " [EmployeeKey] " + " ,[DateKey] " + " ,[CalendarYear] " + " ,[CalendarQuarter] " + " ,[SalesAmountQuota] " + " ,[Date] " + " ) " + "VALUES " + " ( " + " @EmployeeKey " + " ,@DateKey " + " ,@CalendarYear " + " ,@CalendarQuarter " + " ,@SalesAmountQuota " + " ,@Date " + " ) " + ""; SqlCommand insertCommand = new SqlCommand(insertStatement, connection); insertCommand.CommandType = CommandType.Text; insertCommand.Parameters.AddWithValue("@EmployeeKey", clsdbo_FactSalesQuota.EmployeeKey); insertCommand.Parameters.AddWithValue("@DateKey", clsdbo_FactSalesQuota.DateKey); insertCommand.Parameters.AddWithValue("@CalendarYear", clsdbo_FactSalesQuota.CalendarYear); insertCommand.Parameters.AddWithValue("@CalendarQuarter", clsdbo_FactSalesQuota.CalendarQuarter); insertCommand.Parameters.AddWithValue("@SalesAmountQuota", clsdbo_FactSalesQuota.SalesAmountQuota); if (clsdbo_FactSalesQuota.Date.HasValue == true) { insertCommand.Parameters.AddWithValue("@Date", clsdbo_FactSalesQuota.Date); } else { insertCommand.Parameters.AddWithValue("@Date", DBNull.Value); } try { connection.Open(); int count = insertCommand.ExecuteNonQuery(); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }