/// <summary> /// Function to delete account group /// </summary> public void Delete() { try { if (isDefault == true) { Messages.InformationMessage("Can't delete build in account group"); } //else if (PublicVariables.isMessageDelete) //{ else if (Messages.DeleteConfirmation()) { AccountGroupInfo InfoAccountGroup = new AccountGroupInfo(); AccountGroupSP spAccountGroup = new AccountGroupSP(); if ((spAccountGroup.AccountGroupReferenceDelete(decAccountGroupIdForEdit) == -1)) { Messages.ReferenceExistsMessage(); } else { Messages.DeletedMessage(); btnSave.Text = "Save"; btnDelete.Enabled = false; Clear(); } } //} //else //{ // AccountGroupInfo InfoAccountGroup = new AccountGroupInfo(); // AccountGroupSP spAccountGroup = new AccountGroupSP(); // if ((spAccountGroup.AccountGroupReferenceDelete(decAccountGroupIdForEdit) == -1)) // { // Messages.ReferenceExistsMessage(); // } // else // { // Messages.DeletedMessage(); // btnSave.Text = "Save"; // btnDelete.Enabled = false; // Clear(); // } //} } catch (Exception ex) { MessageBox.Show("AG10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void cmbGroupUnder_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbGroupUnder.SelectedValue != null && cmbGroupUnder.SelectedValue.ToString() != "System.Data.DataRowView") { decimal decAccountGroupId = Convert.ToDecimal(cmbGroupUnder.SelectedValue.ToString()); AccountGroupSP spAccountGroup = new AccountGroupSP(); AccountGroupInfo infoAccountGroup = new AccountGroupInfo(); infoAccountGroup = spAccountGroup.AccountGroupView(decAccountGroupId); string strNature = infoAccountGroup.Nature; string strIsAffectGrossProfit = infoAccountGroup.AffectGrossProfit; // string strNature = spAccountGroup.AccountGroupNatureUnderGroup(decAccountGroupId); if (strNature != "NA") { cmbNature.Text = strNature; if (infoAccountGroup.AffectGrossProfit == "1") { cmbAffectGrossProfit.SelectedIndex = 0; } else { cmbAffectGrossProfit.SelectedIndex = 1; } cmbNature.Enabled = false; cmbAffectGrossProfit.Enabled = false; } else { cmbNature.Enabled = true; cmbAffectGrossProfit.Enabled = true; } } } catch (Exception) { } //if (txtAccountGroupName.Text != null && txtAccountGroupName.Text != string.Empty) //{ //} //else //{ // cmbNature.Enabled = true; //} }
/// <summary> /// Function to Update values in account group Table /// </summary> /// <param name="accountgroupinfo"></param> public void AccountGroupEdit(AccountGroupInfo accountgroupinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AccountGroupEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@accountGroupId", SqlDbType.Decimal); sprmparam.Value = accountgroupinfo.AccountGroupId; sprmparam = sccmd.Parameters.Add("@accountGroupName", SqlDbType.VarChar); sprmparam.Value = accountgroupinfo.AccountGroupName; sprmparam = sccmd.Parameters.Add("@groupUnder", SqlDbType.Decimal); sprmparam.Value = accountgroupinfo.GroupUnder; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = accountgroupinfo.Narration; sprmparam = sccmd.Parameters.Add("@isDefault", SqlDbType.Bit); sprmparam.Value = accountgroupinfo.IsDefault; sprmparam = sccmd.Parameters.Add("@nature", SqlDbType.VarChar); sprmparam.Value = accountgroupinfo.Nature; sprmparam = sccmd.Parameters.Add("@affectGrossProfit", SqlDbType.Bit); sprmparam.Value = accountgroupinfo.AffectGrossProfit; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = accountgroupinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = accountgroupinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = accountgroupinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from account group table based on the parameter /// </summary> /// <param name="accountGroupId"></param> /// <returns></returns> public AccountGroupInfo AccountGroupView(decimal accountGroupId) { AccountGroupInfo accountgroupinfo = new AccountGroupInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AccountGroupView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@accountGroupId", SqlDbType.Decimal); sprmparam.Value = accountGroupId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { accountgroupinfo.AccountGroupId = decimal.Parse(sdrreader[0].ToString()); accountgroupinfo.AccountGroupName = sdrreader[1].ToString(); accountgroupinfo.GroupUnder = decimal.Parse(sdrreader[2].ToString()); accountgroupinfo.Narration = sdrreader[3].ToString(); accountgroupinfo.IsDefault = bool.Parse(sdrreader[4].ToString()); accountgroupinfo.Nature = sdrreader[5].ToString(); accountgroupinfo.AffectGrossProfit = sdrreader[6].ToString(); accountgroupinfo.ExtraDate = DateTime.Parse(sdrreader[7].ToString()); accountgroupinfo.Extra1 = sdrreader[8].ToString(); accountgroupinfo.Extra2 = sdrreader[9].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(accountgroupinfo); }
/// <summary> /// Function to get particular values from account group table based on the parameter for update /// </summary> /// <param name="decAccountGroupId"></param> /// <returns></returns> public AccountGroupInfo AccountGroupViewForUpdate(decimal decAccountGroupId) { AccountGroupInfo accountgroupinfo = new AccountGroupInfo(); SqlDataReader sqldr = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("AccountGroupViewForUpdate", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; sccmd.Parameters.Add("@accountGroupId", SqlDbType.Decimal).Value = decAccountGroupId; sqldr = sccmd.ExecuteReader(); while (sqldr.Read()) { accountgroupinfo.AccountGroupId = decimal.Parse(sqldr["accountGroupId"].ToString()); accountgroupinfo.AccountGroupName = sqldr["accountGroupName"].ToString(); accountgroupinfo.GroupUnder = decimal.Parse(sqldr["groupUnder"].ToString()); accountgroupinfo.Narration = sqldr["narration"].ToString(); accountgroupinfo.IsDefault = bool.Parse(sqldr["isDefault"].ToString()); accountgroupinfo.Nature = sqldr["nature"].ToString(); accountgroupinfo.AffectGrossProfit = sqldr["affectGrossProfit"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqldr.Close(); sqlcon.Close(); } return(accountgroupinfo); }
/// <summary> /// Fills to control on cell double click in Datagridview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvAccountGroup_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { AccountGroupInfo InfoAccountGroup = new AccountGroupInfo(); AccountGroupSP spAccountGroup = new AccountGroupSP(); InfoAccountGroup = spAccountGroup.AccountGroupViewForUpdate(Convert.ToDecimal(dgvAccountGroup.CurrentRow.Cells["dgvtxtAccountGroupId"].Value.ToString())); bool Isdefault = InfoAccountGroup.IsDefault; txtAccountGroupName.Text = InfoAccountGroup.AccountGroupName; cmbGroupUnder.SelectedValue = InfoAccountGroup.GroupUnder.ToString(); decimal decAccountGroupId = Convert.ToDecimal(cmbGroupUnder.SelectedValue.ToString()); string strNature = spAccountGroup.AccountGroupNatureUnderGroup(decAccountGroupId); if (strNature != "NA") { cmbNature.Text = InfoAccountGroup.Nature; cmbNature.Enabled = false; } else { cmbNature.Text = InfoAccountGroup.Nature; cmbNature.Enabled = true; } if (Isdefault) { decimal decAffectGrossProfit = Convert.ToDecimal(InfoAccountGroup.AffectGrossProfit); if (decAffectGrossProfit == 0) { cmbAffectGrossProfit.Text = "No"; } else { cmbAffectGrossProfit.Text = "Yes"; } } else { cmbAffectGrossProfit.Text = InfoAccountGroup.AffectGrossProfit; } txtNarration.Text = InfoAccountGroup.Narration; btnSave.Text = "Update"; txtAccountGroupName.Focus(); btnDelete.Enabled = true; strAccountGroupName = InfoAccountGroup.AccountGroupName; decAccountGroupIdForEdit = Convert.ToDecimal(dgvAccountGroup.CurrentRow.Cells["dgvtxtAccountGroupId"].Value.ToString()); inId = Convert.ToInt32(InfoAccountGroup.AccountGroupId.ToString()); isDefault = Convert.ToBoolean(InfoAccountGroup.IsDefault); if (isDefault == true && strNature != "NA") { txtAccountGroupName.Enabled = false; cmbAffectGrossProfit.Enabled = false; cmbGroupUnder.Enabled = false; cmbNature.Enabled = false; } else { if (strNature == "NA") { txtAccountGroupName.Enabled = true; cmbAffectGrossProfit.Enabled = true; cmbGroupUnder.Enabled = true; cmbNature.Enabled = true; } } if (isDefault == false) { if (spAccountGroup.AccountGroupCheckExistenceOfUnderGroup(Convert.ToDecimal(inId.ToString())) == false) { cmbAffectGrossProfit.Enabled = false; cmbGroupUnder.Enabled = false; cmbNature.Enabled = false; } else { if (strNature == "NA") { cmbAffectGrossProfit.Enabled = true; cmbGroupUnder.Enabled = true; cmbNature.Enabled = true; } } } } } catch (Exception ex) { MessageBox.Show("AG18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save and edit account group /// </summary> public void SaveOrEdit() { try { strAccountGroupName = btnSave.Text == "Save" ? string.Empty : strAccountGroupName; if (CheckExistanceOfGroupName() == false) { if (txtAccountGroupName.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter account group name"); txtAccountGroupName.Focus(); } else if (cmbGroupUnder.SelectedIndex == -1) { Messages.InformationMessage("Select under"); cmbGroupUnder.Focus(); } else if (cmbNature.SelectedIndex == -1) { Messages.InformationMessage("Select nature"); cmbNature.Focus(); } else { AccountGroupInfo infoAccountGroup = new AccountGroupInfo(); AccountGroupSP spAccountGroup = new AccountGroupSP(); infoAccountGroup.AccountGroupName = txtAccountGroupName.Text.Trim(); infoAccountGroup.GroupUnder = Convert.ToDecimal(cmbGroupUnder.SelectedValue.ToString()); infoAccountGroup.Nature = cmbNature.SelectedItem.ToString(); if (cmbAffectGrossProfit.SelectedIndex == -1) { infoAccountGroup.AffectGrossProfit = "No"; } else { infoAccountGroup.AffectGrossProfit = cmbAffectGrossProfit.SelectedItem.ToString(); } infoAccountGroup.IsDefault = false; infoAccountGroup.Narration = txtNarration.Text.Trim(); infoAccountGroup.Extra1 = string.Empty; infoAccountGroup.Extra2 = string.Empty; if (btnSave.Text == "Save") { if (Messages.SaveConfirmation()) { decAccountGroupId = spAccountGroup.AccountGroupAddWithIdentity(infoAccountGroup); Messages.SavedMessage(); decIdForOtherForms = decAccountGroupId; if (frmAccountLedgerobj != null) { this.Close(); } GridFill(); Clear(); } } else { if (isDefault == true) { Messages.InformationMessage("Can't update build in account group"); } else if (txtAccountGroupName.Text.Trim().ToLower() != cmbGroupUnder.Text.ToLower()) { if (Messages.UpdateConfirmation()) { infoAccountGroup.AccountGroupId = decAccountGroupIdForEdit; if (spAccountGroup.AccountGroupUpdate(infoAccountGroup)) { Messages.UpdatedMessage(); } GridFill(); Clear(); } } else { Messages.InformationMessage(" Can't save under same group"); } } } } else { Messages.InformationMessage(" Account group already exist"); txtAccountGroupName.Focus(); } } catch (Exception ex) { MessageBox.Show("AG8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }