public int RemoveIncentivePlanForPageCount(InsentiveScheme mDetail) { //insert databse values SqlCommand insetComm = new SqlCommand(); insetComm.Connection = this.mConnectionUser; insetComm.CommandType = CommandType.Text; insetComm.Parameters.Add("@IN_IncentiveMonth", SqlDbType.NVarChar); insetComm.Parameters.Add("@IN_ForPage", SqlDbType.Int); insetComm.Parameters["@IN_IncentiveMonth"].Value = DateTime.Parse(mDetail.IncentiveMonth); insetComm.Parameters["@IN_ForPage"].Value = mDetail.ForPage; insetComm.CommandText = "DELETE FROM IncentiveScheme WHERE IncentiveMonth=@IN_IncentiveMonth AND ForPage=@IN_ForPage"; int ans = insetComm.ExecuteNonQuery(); if (ans > 0) { return(ans); } else { return(0); } }
public int UpdateIncentivePlan(InsentiveScheme mDetail) { //update databse values SqlCommand updateComm = new SqlCommand(); updateComm.Connection = this.mConnectionUser; updateComm.CommandType = CommandType.Text; updateComm.Parameters.Add("@IN_IncentiveMonth", SqlDbType.NVarChar); updateComm.Parameters.Add("@IN_IncentiveAmount", SqlDbType.Money); updateComm.Parameters.Add("@IN_ForBook", SqlDbType.Int); updateComm.Parameters.Add("@IN_ForPage", SqlDbType.Int); updateComm.Parameters.Add("@IN_IncentiveRule", SqlDbType.Int); updateComm.Parameters["@IN_IncentiveMonth"].Value = DateTime.Parse(mDetail.IncentiveMonth); updateComm.Parameters["@IN_IncentiveAmount"].Value = mDetail.IncentiveAmount; updateComm.Parameters["@IN_ForBook"].Value = mDetail.ForBook; updateComm.Parameters["@IN_ForPage"].Value = mDetail.ForPage; updateComm.Parameters["@IN_IncentiveRule"].Value = mDetail.IncentiveRule; updateComm.CommandText = "update IncentiveScheme set IncentiveMonth=@IN_IncentiveMonth,IncentiveAmount=@IN_IncentiveAmount,ForBook=@IN_ForBook,ForPage=@IN_ForPage,IncentiveRule=@IN_IncentiveRule where IncentiveMonth=@IN_IncentiveMonth"; int ans = updateComm.ExecuteNonQuery(); if (ans > 0) { return(ans); } else { return(0); } }
public int AddIncentivePlan(InsentiveScheme mDetail) { //insert databse values SqlCommand insetComm = new SqlCommand(); insetComm.Connection = this.mConnectionUser; insetComm.CommandType = CommandType.Text; insetComm.Parameters.Add("@IN_IncentiveMonth", SqlDbType.NVarChar); insetComm.Parameters.Add("@IN_IncentiveAmount", SqlDbType.Money); insetComm.Parameters.Add("@IN_ForBook", SqlDbType.Int); insetComm.Parameters.Add("@IN_ForPage", SqlDbType.Int); insetComm.Parameters.Add("@IN_IncentiveRule", SqlDbType.Int); insetComm.Parameters["@IN_IncentiveMonth"].Value = DateTime.Parse(mDetail.IncentiveMonth); insetComm.Parameters["@IN_IncentiveAmount"].Value = mDetail.IncentiveAmount; insetComm.Parameters["@IN_ForBook"].Value = mDetail.ForBook; insetComm.Parameters["@IN_ForPage"].Value = mDetail.ForPage; insetComm.Parameters["@IN_IncentiveRule"].Value = mDetail.IncentiveRule; insetComm.CommandText = "INSERT INTO IncentiveScheme(IncentiveMonth,IncentiveAmount,ForBook,ForPage,IncentiveRule) VALUES(@IN_IncentiveMonth,@IN_IncentiveAmount,@IN_ForBook,@IN_ForPage,@IN_IncentiveRule)"; int ans = insetComm.ExecuteNonQuery(); if (ans > 0) { return(ans); } else { return(0); } }
private void btnMakePlan_Click(object sender, EventArgs e) { //validate Incentive Plan if (cmbIncentivePlan.Text != "") { //validate Incentive Amount if (numericUpDownIncentiveAmount.Value > 0) { if (numericUpDownIncentiveLimit.Value > 0) { InsentiveScheme mINS = new InsentiveScheme(); //Initialize Insentive Plan mINS.IncentiveMonth = dateTimePickerIncentiveMonth.Value.ToString("yyyy-MM"); if (cmbIncentivePlan.Text == "Page Count") { mINS.ForBook = 0; mINS.ForPage = 1; } if (cmbIncentivePlan.Text == "Book Count") { mINS.ForBook = 1; mINS.ForPage = 0; } mINS.IncentiveRule = int.Parse(numericUpDownIncentiveLimit.Value.ToString()); mINS.IncentiveAmount = int.Parse(numericUpDownIncentiveAmount.Value.ToString()); InsentiveSchemeMng mINSMng = new InsentiveSchemeMng(conn); if (mINSMng.MonthIsExist(dateTimePickerIncentiveMonth.Value.ToString("yyyy-MM")) == false) { if (mINSMng.AddIncentivePlan(mINS) > 0) { MessageBox.Show("Incentive Plan created for month " + dateTimePickerIncentiveMonth.Value + ".", "Incentive Plan Created", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Incentive plan already exists as " + dateTimePickerIncentiveMonth.Value.ToString("yyyy-MM") + " !\nPlease change the month.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); dateTimePickerIncentiveMonth.Focus(); } } else { MessageBox.Show("Incentive Limit should not be zero or empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); numericUpDownIncentiveLimit.Focus(); } } else { MessageBox.Show("Incentive Amount should not be zero or empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); numericUpDownIncentiveAmount.Focus(); } } else { MessageBox.Show("Incentive Plan canot be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbIncentivePlan.Focus(); } }