private void btnCreate_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to Create ?", "Create New Ledgers", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { progressBar1.Value = 0; progressBar1.Maximum = dgvList.Rows.Count; foreach (DataGridViewRow r in dgvList.Rows ) { if (r.Cells["dgv_Select"].Value == "1") { AccountType.AccountCreationDataType _Savedata = new AccountType.AccountCreationDataType(); string respond = ""; respond = SetDataToClass(r, out _Savedata); if (respond == "True") { if (!Myaccount.ExistAccountCreation(_Savedata.AccountID)) respond = Myaccount.SaveAccountCreation(_Savedata); if (respond != "True") Program.VerningMessage(respond); } } progressBar1.Value = r.Index +1; } Program.InformationMessage("Account Saved Successfully"); progressBar1.Value = 0; } }
private string SetDataToClass( DataGridViewRow r, out AccountType.AccountCreationDataType _Savedata) { _Savedata = new AccountType.AccountCreationDataType(); try { if (btnSupplier.Checked) { if (txtCurrency.Text == "USD") { _Savedata.AccountID = "20005-" + r.Cells["dgvList_ID"].Value.ToString(); _Savedata.MainAccountID = "20005"; } else { _Savedata.AccountID = "20000-" + r.Cells["dgvList_ID"].Value.ToString(); _Savedata.MainAccountID = "20000"; } _Savedata.AccountName = r.Cells["dgvList_Name"].Value.ToString(); _Savedata.AccountStatus = 1; _Savedata.BankAccountNo = ""; _Savedata.CompanyID = Program.AccountStatic.CompanyID; _Savedata.CreatedUser = Program.AccountStatic.UserName; _Savedata.Currency = txtCurrency.Text ; _Savedata.CurrencySymble = txtCurrency.Text ; _Savedata.IsSubAccount = 1; _Savedata.MainAccType = 6; } else if (btnCustomer.Checked) { _Savedata.AccountID = "10105-" + r.Cells["dgvList_ID"].Value.ToString(); _Savedata.AccountName = r.Cells["dgvList_Name"].Value.ToString(); _Savedata.AccountStatus = 1; _Savedata.BankAccountNo = ""; _Savedata.CompanyID = Program.AccountStatic.CompanyID; _Savedata.CreatedUser = Program.AccountStatic.UserName; _Savedata.Currency = txtCurrency.Text ; _Savedata.CurrencySymble = txtCurrency.Text ; _Savedata.IsSubAccount = 1; _Savedata.MainAccountID = "10105"; _Savedata.MainAccType = 2; } return "True"; } catch (Exception ex) { return ex.Message; } }
public string GetExistAccountCreation(string AccountID, out AccountType.AccountCreationDataType _ExistData) { _ExistData = new AccountType.AccountCreationDataType(); MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Select " + "SysID," + "AccountID," + "AccountName," + "MainAccType," + "IsSubAccount," + "MainAccountID," + "AccountStatus," + "Currency," + "CurrencySymble," + "BankAccountNo," + "LastVoucherID," + "LastTransRef," + "CreatedUser," + "lastaccdate,CompanyID" + " from accountname" + " Where 1=1 " + " and AccountID=@AccountID"; oSqlCommand.Parameters.AddWithValue("@AccountID", AccountID); DataRow r = Mycommon.GetDataRowAccount(sqlQuery, oSqlCommand, "Get Exist data AccountCreation"); if (r != null) { try { bool resp = false; int inSysID = 0; resp = int.TryParse(r["SysID"].ToString(), out inSysID); _ExistData.SysID = inSysID; _ExistData.AccountID = r["AccountID"].ToString(); _ExistData.AccountName = r["AccountName"].ToString(); int inMainAccType = 0; resp = int.TryParse(r["MainAccType"].ToString(), out inMainAccType); _ExistData.MainAccType = inMainAccType; int inIsSubAccount = 0; resp = int.TryParse(r["IsSubAccount"].ToString(), out inIsSubAccount); _ExistData.IsSubAccount = inIsSubAccount; _ExistData.MainAccountID = r["MainAccountID"].ToString(); int inAccountStatus = 0; resp = int.TryParse(r["AccountStatus"].ToString(), out inAccountStatus); _ExistData.AccountStatus = inAccountStatus; _ExistData.Currency = r["Currency"].ToString(); _ExistData.CurrencySymble = r["CurrencySymble"].ToString(); _ExistData.BankAccountNo = r["BankAccountNo"].ToString(); int inLastVoucherID = 0; resp = int.TryParse(r["LastVoucherID"].ToString(), out inLastVoucherID); _ExistData.LastVoucherID = inLastVoucherID; _ExistData.LastTransRef = r["LastTransRef"].ToString(); _ExistData.CreatedUser = r["CreatedUser"].ToString(); DateTime dtlastaccdate = new DateTime(1900, 1, 1); resp = DateTime.TryParse(r["lastaccdate"].ToString(), out dtlastaccdate); if (resp) _ExistData.lastaccdate = dtlastaccdate; else _ExistData.lastaccdate = new DateTime(1900, 1, 1); int inCompanyID = 0; resp = int.TryParse(r["CompanyID"].ToString(), out inCompanyID); _ExistData.CompanyID = inCompanyID; return "True"; } catch (Exception ex) { return ex.Message; } } else return "data not found "; }
private void btnUpdate_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to Update Creent Record ", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { AccountType.AccountCreationDataType _Savedata = new AccountType.AccountCreationDataType(); string respond = SetDataToCLass(out _Savedata); if (MyAccount.ExistAccountCreation(_Savedata.AccountID)) { if (respond == "True") { respond = MyAccount.UpdateAccountCreation(_Savedata); if (respond == "True") { MessageBox.Show("Record Saved Successfully", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadExistingAccount(); LoadExtAccountInHiaraky(); } else MessageBox.Show(respond, "E r r o r", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else MessageBox.Show(respond, "E r r o r", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { MessageBox.Show("No account Number in the system, Use Save Button to Add new account delatails", "E r r o r", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
private void DisplayExtData(string AccNo) { AccountType.AccountCreationDataType _Savedata = new AccountType.AccountCreationDataType(); string respond = MyAccount.GetExistAccountCreation(AccNo, out _Savedata); InitializeScreen(); ComboboxItem cmb = new ComboboxItem(); if (respond == "True") { txtAccID.Text = _Savedata.AccountID.ToString (); txtAccountDescription.Text = _Savedata.AccountName; cmbAccountType.Text = cmb.GetReleventTextFromID(cmbAccountType, _Savedata.MainAccType.ToString(), true); if (_Savedata.IsSubAccount == 1) { chkIsSubaccount.CheckState = CheckState.Checked; cmbMainAccount.Text = cmb.GetReleventTextFromID(cmbMainAccount, _Savedata.MainAccountID.ToString (), true); } else chkIsSubaccount.CheckState = CheckState.Unchecked; cmbCurrenyType.Text = cmb.GetReleventTextFromID(cmbCurrenyType, _Savedata.Currency , true); cmbBankAccountNo.Text = _Savedata.BankAccountNo; cmbAccStatus.Text = cmb.GetReleventTextFromID(cmbAccStatus, _Savedata.AccountStatus.ToString (), true); } }
private string SetDataToCLass(out AccountType.AccountCreationDataType _Savedata) { ComboboxItem cmb=new ComboboxItem(); _Savedata = new AccountType.AccountCreationDataType(); _Savedata.AccountID = txtAccID.Text; _Savedata.AccountName = txtAccountDescription.Text; _Savedata.AccountStatus = int.Parse(cmb .GetReleventTextFromID(cmbAccStatus,cmbAccStatus.Text ,false)); _Savedata.BankAccountNo = cmbBankAccountNo.Text; _Savedata.CreatedUser = Program.AccountStatic.UserName; _Savedata.Currency = cmbCurrenyType.Text; if (chkIsSubaccount.CheckState == CheckState.Checked) { _Savedata.IsSubAccount = 1; _Savedata.MainAccountID = cmb.GetReleventTextFromID(cmbMainAccount, cmbMainAccount.Text, false ); } else { _Savedata.IsSubAccount = 0; _Savedata.MainAccountID = "0"; } _Savedata.lastaccdate = DateTime.Today; _Savedata.MainAccType = int.Parse(cmb.GetReleventTextFromID(cmbAccountType, cmbAccountType.Text, false)); _Savedata.CompanyID = Program.AccountStatic.CompanyID; return "True"; }