private void addPurchaseDetails() { _entities = new MicroAccountsEntities1(); var data1 = _entities.tbl_PurchaseDetail.Where(x => x.purchaseID == passedId).ToList(); List <PurchaseDetailsVM> DetailslistVm = new List <PurchaseDetailsVM>(); foreach (var item in data1) { PurchaseDetailsVM vm = new PurchaseDetailsVM(); vm.purchaseID = item.purchaseID; vm.making = item.making; vm.melting = item.melting; vm.ItemCode = _entities.tbl_ItemMaster.Where(x => x.id == item.productID).FirstOrDefault().itemCode; vm.weight = item.weight; vm.unit = item.unit; vm.rate = item.rate; vm.karat = item.karat; vm.kRate = item.kRate; vm.purchaseMelting = item.purchaseMelting; DetailslistVm.Add(vm); } ReportDataSource datasource1 = new ReportDataSource("DataSet2", DetailslistVm); this.reportViewer1.LocalReport.DataSources.Add(datasource1); }
public void DataGridSource() { int rowNo = 1; dgRegisteredUser.AutoGenerateColumns = false; _entities = new MicroAccountsEntities1(); List <UserProfileVM> modelList = new List <UserProfileVM>(); var dataList = _entities.tbl_UserProfile.ToList(); foreach (var item in dataList) { UserProfileVM model = new UserProfileVM(); model.rowNo = rowNo; model.firstName = item.firstName; model.lastName = item.lastName; model.mobile = item.mobile; model.email = item.email; model.userId = item.userId; model.createdDate = Convert.ToDateTime(item.createdDate).ToString("dd-MM-yyyy hh:mm tt"); model.updateDate = Convert.ToDateTime(item.updateDate).ToString("dd-MM-yyyy hh:mm tt"); modelList.Add(model); rowNo++; } dgRegisteredUser.DataSource = modelList; lblTotalRows.Text = modelList.Count.ToString(); }
private void dgSalesDetails_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dgSalesDetails.Columns[e.ColumnIndex].Name == "Delete") { DialogResult myResult; myResult = MessageBox.Show("Are you really delete the item?", "Delete Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { _entities = new MicroAccountsEntities1(); var cellId = Convert.ToInt32(dgSalesDetails.CurrentRow.Cells[0].Value); #region delete From TransactionTable var selectedData3 = _entities.tbl_TransactionMaster.Where(x => x.voucherRefNo == cellId).ToList(); foreach (var item1 in selectedData3) { _entities.tbl_TransactionMaster.Remove(item1); _entities.SaveChanges(); } #endregion var selectedData1 = _entities.tbl_SalesDetails.Where(x => x.salesId == cellId).FirstOrDefault(); var selectedData2 = _entities.tbl_SalesMaster.Where(x => x.sId == cellId).FirstOrDefault(); if (selectedData1 != null) { _entities.tbl_SalesDetails.Remove(selectedData1); } else { MessageBox.Show("Something went wrong. Record cannot be deleted."); } if (selectedData2 != null) { _entities.tbl_SalesMaster.Remove(selectedData2); } else { MessageBox.Show("Something went wrong. Record cannot be deleted."); } _entities.SaveChanges(); MessageBox.Show("Record deleted "); dataGridBind(); } else { //No delete } } } catch (Exception x) { MessageBox.Show("Record Cannot be deleted. Reference of this record is present in other entries"); } }
public string[] opening_diff(int accnt_id) { acc = new MicroAccountsEntities1(); var ledger = from c in acc.tbl_AccLedger select c; foreach (tbl_AccLedger ledg in ledger) { if (ledg.opBalanceDC == "D") { total_op = Convert.ToDecimal(total_op + ledg.opBalance); } else { total_op = Convert.ToDecimal(total_op - ledg.opBalance); } } if (total_op >= 0) { string[] op_array = new string[] { "C", Convert.ToDecimal(total_op).ToString() }; return(op_array); } else { string[] op_array = new string[] { "D", Convert.ToDecimal(total_op).ToString() }; return(op_array); } }
private void StockInventoryDetails_Load(object sender, EventArgs e) { dataGridBind(); itemNameAutoComplete(); cmbKarat.SelectedIndex = 0; _entities = new MicroAccountsEntities1(); var data = _entities.tbl_CategoryMaster.ToList(); List <CategoryMasterVM> catList = new List <CategoryMasterVM>(); CategoryMasterVM model = new CategoryMasterVM(); model.cName = "--Select--"; model.cId = -1; catList.Add(model); foreach (var item in data) { model = new CategoryMasterVM(); model.cId = item.cId; model.cName = item.cName; catList.Add(model); } cmbCategory.DataSource = catList; cmbCategory.DisplayMember = "cName"; cmbCategory.ValueMember = "cId"; }
private void txtLedgerName_KeyUp(object sender, KeyEventArgs e) { try { dgStockDetails.AutoGenerateColumns = false; int rowNos = 1; _entities = new MicroAccountsEntities1(); List <tbl_ItemMaster> data; if (txtLedgerName.Text == "") { data = _entities.tbl_ItemMaster.ToList(); } else { data = _entities.tbl_ItemMaster.Where(x => x.itemCode.Contains(txtLedgerName.Text.Trim().ToString())).ToList(); } modelList = new List <ItemMasterVM>(); foreach (var item in data) { ItemMasterVM model = new ItemMasterVM(); model.rowNo = rowNos; model.id = item.id; model.categoryName = _entities.tbl_CategoryMaster.Where(x => x.cId == item.categoryId).FirstOrDefault().cName.ToString(); model.itemCode = item.itemCode; model.photo = item.photo; var itemDetail = _entities.tbl_StockItemDetails.Where(x => x.itemId == item.id).FirstOrDefault(); model.weight = (itemDetail.weight.ToString() + " " + itemDetail.unit.ToString()).ToString(); model.carret = itemDetail.carret; model.qty = Convert.ToInt32(itemDetail.qty); model.melting = itemDetail.melting; model.createdDate = Convert.ToDateTime(item.createdDate).ToString("dd-MM-yyyy hh:mm tt"); model.updatedDate = Convert.ToDateTime(item.updateDate).ToString("dd-MM-yyyy hh:mm tt"); modelList.Add(model); rowNos++; } dgStockDetails.DataSource = modelList; lblTotalRows.Text = modelList.Count.ToString(); for (int i = 0; i < dgStockDetails.Rows.Count; i++) { if (dgStockDetails.Columns[2] is DataGridViewImageColumn) { ((DataGridViewImageColumn)dgStockDetails.Columns[2]).ImageLayout = DataGridViewImageCellLayout.Stretch; break; } } dgStockDetails.RowTemplate.Height = 80; } catch (Exception x) { } }
void comboBoxBind() { try { _entities = new MicroAccountsEntities1(); var data = _entities.tbl_CategoryMaster; List <CategoryMasterVM> modellist = new List <CategoryMasterVM>(); CategoryMasterVM model = new CategoryMasterVM(); model.cId = -1; model.cName = "--Select--"; modellist.Add(model); foreach (var item in data) { model = new CategoryMasterVM(); model.cId = item.cId; model.cName = item.cName; modellist.Add(model); } cmbItemCategory.DataSource = modellist.ToList(); cmbItemCategory.DisplayMember = "cName"; cmbItemCategory.ValueMember = "cId"; } catch (Exception x) { } }
private void dgRegisteredUser_DoubleClick(object sender, EventArgs e) { if (dgRegisteredUser.CurrentRow.Index != -1) { _entities = new MicroAccountsEntities1(); EncryptionDecription enc = new EncryptionDecription(); var uID = Convert.ToInt32(dgRegisteredUser.CurrentRow.Cells["SrNo"].Value); var userJoinData = (from a in _entities.tbl_UserProfile join b in _entities.tbl_UserLogiln on a.userId equals b.userId where a.userId == uID select new { a, b }).FirstOrDefault(); txtEmail.Text = userJoinData.a.email; txtF_name.Text = userJoinData.a.firstName; txtL_name.Text = userJoinData.a.lastName; txtMobileNo.Text = userJoinData.a.mobile.ToString(); //txtNewPass.Text = enc.Decrypt(userJoinData.b.password, "sblw-3hn8-sqoy19").ToString(); //txtNewPass.Text = enc.Decrypt(userJoinData.b.password).ToString(); txtNewPass.Text = userJoinData.b.password.Trim().ToString(); txtUserName.Text = userJoinData.b.loginId.ToString(); hiddenUID.Text = userJoinData.a.userId.ToString(); btnRegister.Text = "Update"; } }
private void cmbItemCategory_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbItemCategory.SelectedIndex > 0) { _entities = new MicroAccountsEntities1(); // MessageBox.Show(cmbItemCategory.SelectedIndex.ToString()); var categoryId = Convert.ToInt32(cmbItemCategory.SelectedValue); var prefix = _entities.tbl_CategoryMaster.Where(x => x.cId == categoryId).FirstOrDefault().prefix; // lblItemCode.Text = prefix + "-" + DateTime.Now.Year + "001"; var getLastId = _entities.tbl_ItemMaster.OrderByDescending(x => x.id).FirstOrDefault(); if (getLastId == null) { string str = DateTime.Now.ToString("yy"); lblItemCode.Text = prefix + "-" + str + "01"; } else { string str = DateTime.Now.ToString("yy"); var idInc = (getLastId.id) + 1; lblItemCode.Text = prefix + "-" + str + "0" + idInc.ToString(); } } } catch (Exception x) { MessageBox.Show("Something went wrong. Contact your system administrator"); } }
private void dtCategoryList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dtCategoryList.Columns[e.ColumnIndex].Name == "Delete") { DialogResult myResult; myResult = MessageBox.Show("Are you really delete the item?", "Delete Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { //Delete Code _entities = new MicroAccountsEntities1(); var cellId = Convert.ToInt32(dtCategoryList.CurrentRow.Cells[0].Value); var selectedData = _entities.tbl_CategoryMaster.Where(x => x.cId == cellId).FirstOrDefault(); _entities.tbl_CategoryMaster.Remove(selectedData); _entities.SaveChanges(); MessageBox.Show("Record deleted "); dataGridBind(); } else { //No delete } } } catch (Exception x) { MessageBox.Show("Something went wrong. Contact your system administrator"); } }
void addPurchaseDetailsData() { foreach (DataGridViewRow dr in dgSalesItem.Rows) { if (Convert.ToString(dr.Cells[0].Value) != string.Empty) { _entities = new MicroAccountsEntities1(); tbl_SalesDetails salesDetails = new tbl_SalesDetails(); salesDetails.salesId = _entities.tbl_SalesMaster.Where(x => x.billNo == txtBillNo.Text).FirstOrDefault().sId; var gridItemCode = dr.Cells[1].Value.ToString(); salesDetails.productId = _entities.tbl_ItemMaster.Where(x => x.itemCode == gridItemCode).FirstOrDefault().id; salesDetails.qty = Convert.ToDecimal(dr.Cells[2].Value.ToString()); salesDetails.weight = Convert.ToDecimal(dr.Cells[3].Value.ToString()); salesDetails.unit = dr.Cells[4].Value.ToString(); salesDetails.karat = Convert.ToDecimal(dr.Cells[5].Value.ToString()); salesDetails.making = Convert.ToDecimal(dr.Cells[6].Value.ToString()); salesDetails.rate = Convert.ToDecimal(dr.Cells[7].Value.ToString()); salesDetails.createdDate = DateTime.Now; _entities.tbl_SalesDetails.Add(salesDetails); _entities.SaveChanges(); //Update Qty in stock var itemQty = _entities.tbl_StockItemDetails.Where(x => x.itemId == salesDetails.productId).FirstOrDefault(); itemQty.qty = itemQty.qty - salesDetails.qty; itemQty.upadtedDate = DateTime.Now; _entities.SaveChanges(); } } }
private void txtItemCode_Leave(object sender, EventArgs e) { _entities = new MicroAccountsEntities1(); if (txtItemCode.Text != string.Empty) { var checkItemCode = _entities.tbl_ItemMaster.Where(x => x.itemCode == txtItemCode.Text.Trim().ToString()).FirstOrDefault(); if (checkItemCode == null) { DialogResult myResult; myResult = MessageBox.Show("No such item exists. Want to create new item?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { Item items = new Item(0); items.ShowDialog(); txtItemCode.Focus(); } else { txtItemCode.Focus(); } } } }
private void dgLedgerDetails_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dgLedgerDetails.Columns[e.ColumnIndex].Name == "Delete") { DialogResult myResult; myResult = MessageBox.Show("Are you really delete the item?", "Delete Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { _entities = new MicroAccountsEntities1(); var cellId = Convert.ToInt32(dgLedgerDetails.CurrentRow.Cells[0].Value); var selectedData1 = _entities.tbl_LedgerDetails.Where(x => x.ledgerId == cellId).FirstOrDefault(); var selectedData2 = _entities.tbl_AccLedger.Where(x => x.Id == cellId).FirstOrDefault(); _entities.tbl_LedgerDetails.Remove(selectedData1); _entities.tbl_AccLedger.Remove(selectedData2); _entities.SaveChanges(); MessageBox.Show("Record deleted "); dataGridBind(); } } } catch (Exception x) { MessageBox.Show("Record Cannot be deleted. Reference of this record is present in other entries"); } }
private void txtBillNo_Leave(object sender, EventArgs e) { try { if (passedSid == 0 && count == 0) { _entities = new MicroAccountsEntities1(); var id = _entities.tbl_SalesMaster.Where(x => x.billNo == txtBillNo.Text.Trim().ToString()).FirstOrDefault(); if (id != null) { passedSid = Convert.ToInt32(id.sId); showAvailData(); MessageBox.Show("Record of this Bill No./Ref No. already exists. Enter another ref. No. "); txtBillNo.Focus(); count++; } } } catch (Exception x) { } }
private void btnCreate_Click(object sender, EventArgs e) { try { foreach (DataGridViewRow dr in dgBillRef.Rows) { if (Convert.ToString(dr.Cells[0].Value) != string.Empty) { _entities = new MicroAccountsEntities1(); tbl_EntryDetails pd = new tbl_EntryDetails(); // var vNo = _entities.tbl_Payment.OrderByDescending(x => x.voucherRefNo).FirstOrDefault().voucherRefNo; int pId = Convert.ToInt32(dr.Cells[0].Value); pd.voucherRefNo = passedVoucherNo; pd.purchaseSalesIds = pId; pd.amtPaid = Convert.ToDecimal(dr.Cells[4].Value); pd.createdDate = DateTime.Now; _entities.tbl_EntryDetails.Add(pd); _entities.SaveChanges(); this.Close(); comestoUpdate = false; } } } catch (Exception x) { MessageBox.Show(x.ToString()); } }
private void cmbLedgerCR_Leave(object sender, EventArgs e) { _entities = new MicroAccountsEntities1(); if (cmbLedgerCR.Text != string.Empty && cmbLedgerCR.SelectedIndex > 0) { var checkLedgername = _entities.tbl_AccLedger.Where(x => x.ledgerName == cmbLedgerCR.Text.Trim().ToString()).FirstOrDefault(); if (checkLedgername == null) { DialogResult myResult; myResult = MessageBox.Show("No such party exists. Want to create new party?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { AccountLedger ledger = new AccountLedger(0, cmbLedgerCR.Text.Trim().ToString()); ledger.ShowDialog(); cmbLedgerCR.Focus(); } else { cmbLedgerCR.Focus(); } } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgRegisteredUser.Columns[e.ColumnIndex].Name == "Delete") { DialogResult myResult; myResult = MessageBox.Show("Are you really delete the item?", "Delete Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { _entities = new MicroAccountsEntities1(); var cellId = Convert.ToInt32(dgRegisteredUser.CurrentRow.Cells["SrNo"].Value); var selectedData1 = _entities.tbl_UserProfile.Where(x => x.userId == cellId).FirstOrDefault(); var selectedData2 = _entities.tbl_UserLogiln.Where(x => x.userId == cellId).FirstOrDefault(); _entities.tbl_UserProfile.Remove(selectedData1); _entities.tbl_UserLogiln.Remove(selectedData2); _entities.SaveChanges(); MessageBox.Show("Record deleted "); DataGridSource(); } else { //No delete } } }
private void button1_Click(object sender, EventArgs e) { try { int rowNo = 1; dgPurchaseDetails.AutoGenerateColumns = false; _entities = new MicroAccountsEntities1(); List <PurchaseMasterVM> purchaseMasterList = new List <PurchaseMasterVM>(); List <tbl_PurchaseMaster> data = new List <tbl_PurchaseMaster>(); DateTime fromdate = DateTime.ParseExact(dateTimePicker1.Text, "dd-MM-yyyy", null); DateTime todate = DateTime.ParseExact(dateTimePicker2.Text, "dd-MM-yyyy", null); if (fromdate > todate) { MessageBox.Show("Invalid date entered. Select valid dates"); return; } else { if (txtSearch.Text == string.Empty) { data = _entities.tbl_PurchaseMaster.Where(x => x.date >= fromdate && x.date <= todate).OrderByDescending(x => x.pId).ToList(); } else { data = _entities.tbl_PurchaseMaster.Where(x => x.date >= fromdate && x.date <= todate && x.tbl_AccLedger.ledgerName.Contains(txtSearch.Text.Trim().ToString())).OrderByDescending(x => x.pId).ToList(); } foreach (var item in data) { PurchaseMasterVM model = new PurchaseMasterVM(); model.rowNo = rowNo; model.pId = item.pId; model.refNo = item.refNo; model.ledgerName = _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().ledgerName; model.date = Convert.ToDateTime(item.date).ToString("dd-MM-yyyy"); model.totalWeight = item.totalWeight; model.totalAmt = item.totalAmt; model.totalMelting = item.totalMelting; model.createdDate = Convert.ToDateTime(item.createdDate).ToString("dd-MM-yyyy hh:mm tt"); model.updateDate = Convert.ToDateTime(item.updateDate).ToString("dd-MM-yyyy hh:mm tt"); purchaseMasterList.Add(model); rowNo++; } dgPurchaseDetails.DataSource = purchaseMasterList; lblTotalRows.Text = purchaseMasterList.Count.ToString(); } } catch (Exception x) { } }
private void txtLedgerName_KeyUp(object sender, KeyEventArgs e) { try { int rowNo = 1; dgLedgerDetails.AutoGenerateColumns = false; _entities = new MicroAccountsEntities1(); List <LedgerDetailsVM> ledgerDetailsListVM = new List <LedgerDetailsVM>(); List <tbl_LedgerDetails> data; if (txtLedgerName.Text == "") { data = _entities.tbl_LedgerDetails.ToList(); } else { data = _entities.tbl_LedgerDetails.Where(x => x.tbl_AccLedger.ledgerName.Contains(txtLedgerName.Text.Trim().ToString())).ToList(); } foreach (var item in data) { LedgerDetailsVM list = new LedgerDetailsVM(); list.rowNo = rowNo; list.id = item.ledgerId; list.ledgerName = _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().ledgerName; var grpId = _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().groupId; list.groupName = _entities.tbl_AccGroup.Where(x => x.groupId == grpId).FirstOrDefault().groupName.ToString(); list.contact = item.contact; list.address = item.address; var drcr = _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().opBalanceDC; if (drcr == "D") { list.OpBalWithDC = "Dr " + _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().opBalance; } else { list.OpBalWithDC = "Cr " + _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().opBalance; } ledgerDetailsListVM.Add(list); rowNo++; } dgLedgerDetails.DataSource = ledgerDetailsListVM; lblTotalRows.Text = ledgerDetailsListVM.Count.ToString(); } catch (Exception x) { } }
public void print_account_chart(Acc_list account, int c = 0, object ths = null) { MicroAccountsEntities1 accs = new MicroAccountsEntities1(); int count = c; acc_list = new Acc_list(); if (account != null) { if (account.id != 0) { } if (account.children_ledgers.Count() > 0) { count++; // Store keys in a List List <int> list = new List <int>(account.children_ledgers.Keys); // Loop through list foreach (int k in list) { dm = new DummyList(); dm.ledger = account.children_ledgers[k].name; dm.opBal = toCurr.toCurrenc(account.children_ledgers[k].op_total_dc, account.children_ledgers[k].op_total); dm.drAmt = toCurr.toCurrenc("D", account.children_ledgers[k].dr_total); dm.crAmt = toCurr.toCurrenc("C", account.children_ledgers[k].dr_total); if (account.children_ledgers[k].cl_total_dc == "D") { dm.clBal = toCurr.toCurrenc("D", account.children_ledgers[k].dr_total); } else { dm.clBal = toCurr.toCurrenc("C", account.children_ledgers[k].dr_total); } dmList.Add(dm); } count--; } foreach (Acc_list acc in account.children_groups) { count++; print_account_chart(acc, count, this); count--; } //PlaceHolder3.Controls.Add(new Literal { Text = html.ToString() }); } }
void datagridBind() { dgPaymentDetails.AutoGenerateColumns = false; int rowNo = 1; _entities = new MicroAccountsEntities1(); // if (passedVoucherType == 1) { #region Payment Details in Grid List <EntryVM> modelList = new List <EntryVM>(); var data = _entities.tbl_Entry.OrderByDescending(x => x.voucherRefNo).Where(x => x.entryType == passedVoucherType).ToList(); foreach (var item in data) { EntryVM model = new EntryVM(); model.rowNo = rowNo; model.voucherRefNo = item.voucherRefNo; var drLedger = _entities.tbl_AccLedger.Where(x => x.Id == item.drId).FirstOrDefault().ledgerName.ToString(); var crLedger = _entities.tbl_AccLedger.Where(x => x.Id == item.crId).FirstOrDefault().ledgerName.ToString(); model.drcrLedger = "Dr. " + drLedger + " / " + "Cr. " + crLedger; model.amt = Convert.ToDecimal(amtFormat.comma(item.amt)); model.date = Convert.ToDateTime(item.date).ToString("dd-MM-yyyy"); modelList.Add(model); rowNo++; } dgPaymentDetails.DataSource = modelList; lblTotalRows.Text = modelList.Count.ToString(); #endregion } // else if (passedVoucherType == 2) { #region Receipt Details in Grid #endregion } // else if (passedVoucherType == 3) { #region Journal Details in Grid #endregion } // else { #region Contra Details in Grid #endregion } }
private void txtLedgerName_KeyUp(object sender, KeyEventArgs e) { try { dgReceivableAmt.AutoGenerateColumns = false; int rowNo = 1; _entities = new MicroAccountsEntities1(); List <tbl_AccLedger> data = new List <tbl_AccLedger>(); if (txtLedgerName.Text == "") { data = _entities.tbl_AccLedger.Where(x => x.tbl_AccGroup.groupName == "Sundry Debtors").ToList(); } else { data = _entities.tbl_AccLedger.Where(x => x.tbl_AccGroup.groupName == "Sundry Debtors" && x.ledgerName.Contains(txtLedgerName.Text.ToString())).ToList(); } List <LedgerDetailsVM> modelList = new List <LedgerDetailsVM>(); decimal ttlAmt = 0; foreach (var item in data) { LedgerDetailsVM model = new LedgerDetailsVM(); CrDrDifference crdrDiff = new CrDrDifference(); string valueAmt = crdrDiff.DifferenceCrDr(Convert.ToInt32(item.Id), 0); string valueAmtDR = valueAmt.Substring(0, 2); if (valueAmtDR == "Dr") { string pAmtString = valueAmt.Substring(3); model.rowNo = rowNo; model.id = item.Id; model.ledgerName = item.ledgerName.ToString(); model.pendingAmt = Convert.ToDecimal(amtFormat.comma(Convert.ToDecimal(pAmtString))); rowNo++; modelList.Add(model); ttlAmt += Convert.ToDecimal(pAmtString); lblTotalAmt.Text = amtFormat.comma(ttlAmt).ToString(); } } dgReceivableAmt.DataSource = modelList; lblTotalRows.Text = modelList.Count.ToString(); } catch (Exception x) { } }
public void start(int acc_id) { if (acc_id == 0) { this.id = Convert.ToInt32(null); this.name = "None"; } else { acc = new MicroAccountsEntities1(); var group = (from c in acc.tbl_AccGroup where c.id == acc_id select c).FirstOrDefault(); //var group = (from c in acc.Groups // where c.account_id == account_id // select c).FirstOrDefault(); if (group != null) { this.g_idd = Convert.ToInt32(group.groupId); this.id = Convert.ToInt32(group.id); this.name = group.groupName; this.g_parent_id = Convert.ToInt32(group.parentId); this.g_affects_gross = Convert.ToInt32(group.affects_gross); // this.a_id = Convert.ToInt32(group.account_id); } //else //{ // this.a_id = account_id; // // this.a_id = account_id; //} } this.op_total = 0; this.op_total_dc = "D"; this.dr_total = 0; this.cr_total = 0; this.cl_total = 0; this.cl_total_dc = "D"; if (this.affects_gross == 1) { } else if (this.affects_gross == 0) { this.add_sub_ledgers(); } else { this.add_sub_ledgers(); } this.add_sub_groups(); }
public void DataGridSource() { int rowNo = 1; dtGroupList.AutoGenerateColumns = false; _entities = new MicroAccountsEntities1(); List <AccGroupVM> accList = new List <AccGroupVM>(); var data = _entities.tbl_AccGroup; foreach (var item in data) { AccGroupVM accVM = new AccGroupVM(); accVM.rowNo = rowNo; accVM.groupId = item.groupId; accVM.groupName = item.groupName.Trim(); if (item.parentId > 0) { accVM.ParentGroupName = _entities.tbl_AccGroup.Where(x => x.id == item.parentId).FirstOrDefault().groupName; } if (item.parentId <= 0) { accVM.ParentGroupName = "--"; } accVM.createdDate = Convert.ToDateTime(item.createdDate).ToString("dd-MM-yyyy hh:mm tt"); if (item.updateDate == null) { accVM.updateDate = "--"; } else { accVM.updateDate = Convert.ToDateTime(item.updateDate).ToString("dd-MM-yyyy hh:mm tt"); } accList.Add(accVM); rowNo++; } dtGroupList.DataSource = accList; //Combo Box Binding _entities = new MicroAccountsEntities1(); var datas = _entities.tbl_AccGroup.ToList(); cmbParentGroup.DataSource = datas.ToList(); cmbParentGroup.DisplayMember = "groupName"; cmbParentGroup.ValueMember = "groupId"; lblTotalRows.Text = accList.Count.ToString(); }
private void dgPaymentDetails_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dgPaymentDetails.Columns[e.ColumnIndex].Name == "Delete") { DialogResult myResult; myResult = MessageBox.Show("Are you really delete the item?", "Delete Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (myResult == DialogResult.OK) { _entities = new MicroAccountsEntities1(); var cellId = Convert.ToInt32(dgPaymentDetails.CurrentRow.Cells[0].Value); #region delete From TransactionTable var selectedData1 = _entities.tbl_TransactionMaster.Where(x => x.voucherRefNo == cellId).ToList(); foreach (var item1 in selectedData1) { _entities.tbl_TransactionMaster.Remove(item1); } #endregion #region delete From Payment Details Table var selectedData2 = _entities.tbl_EntryDetails.Where(x => x.voucherRefNo == cellId).ToList(); foreach (var item2 in selectedData2) { _entities.tbl_EntryDetails.Remove(item2); } #endregion #region delete From Payment Master Table var selectedData3 = _entities.tbl_Entry.Where(x => x.voucherRefNo == cellId).FirstOrDefault(); _entities.tbl_Entry.Remove(selectedData3); #endregion _entities.SaveChanges(); MessageBox.Show("Record deleted "); clear(); datagridBind(); } else { } } } catch (Exception x) { } }
public void bindComboBox() { //Combo Box Binding _entities = new MicroAccountsEntities1(); var datas = _entities.tbl_AccGroup; cmbParentGroup.DataSource = datas.ToList(); cmbParentGroup.DisplayMember = "groupName"; cmbParentGroup.ValueMember = "groupId"; }
private void itemNameAutoComplete() { _entities = new MicroAccountsEntities1(); var itemCodeAutoComplete = _entities.tbl_ItemMaster; txtLedgerName.AutoCompleteCustomSource.Clear(); foreach (var item in itemCodeAutoComplete) { txtLedgerName.AutoCompleteCustomSource.Add(item.itemCode.ToString()); } }
private void dgStockDetails_DoubleClick(object sender, EventArgs e) { if (dgStockDetails.CurrentRow.Index != -1) { _entities = new MicroAccountsEntities1(); var itemID = Convert.ToInt32(dgStockDetails.CurrentRow.Cells[0].Value); Item it = new Item(itemID); it.ShowDialog(); dataGridBind(); } }
private void addPurchaseMaster() { _entities = new MicroAccountsEntities1(); var data = _entities.tbl_PurchaseMaster.Where(x => x.pId == passedId).ToList(); List <PurchaseMasterVM> listVm = new List <PurchaseMasterVM>(); List <LedgerDetailsVM> LedgerlistVm = new List <LedgerDetailsVM>(); foreach (var item in data) { PurchaseMasterVM vm = new PurchaseMasterVM(); vm.date = Convert.ToDateTime(item.date).Date.ToString("dd-MM-yyyy"); vm.ledgerName = _entities.tbl_AccLedger.Where(x => x.Id == item.ledgerId).FirstOrDefault().ledgerName; vm.ledgerId = item.ledgerId; vm.pId = item.pId; vm.refNo = item.refNo; vm.remarks = item.remarks; vm.totalFine = item.totalFine; vm.totalMaking = item.totalMaking; vm.totalMelting = item.totalMelting; vm.totalWeight = item.totalWeight; vm.unit = item.unit; vm.totalAmt = item.totalAmt; ConvertNoToWord toWord = new ConvertNoToWord(); vm.amtinWord = toWord.ConvertNumbertoWords(Convert.ToInt32(item.totalAmt)); listVm.Add(vm); LedgerDetailsVM ll = new LedgerDetailsVM(); ll.contact = _entities.tbl_LedgerDetails.Where(x => x.ledgerId == item.ledgerId).FirstOrDefault().contact; ll.address = _entities.tbl_LedgerDetails.Where(x => x.ledgerId == item.ledgerId).FirstOrDefault().address.Trim(); LedgerlistVm.Add(ll); } ReportDataSource datasource = new ReportDataSource("DataSet1", listVm); this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(datasource); datasource = new ReportDataSource("DataSet3", LedgerlistVm); this.reportViewer1.LocalReport.DataSources.Add(datasource); }
private void button1_Click(object sender, EventArgs e) { try { _entities = new MicroAccountsEntities1(); int rowNo = 1; dgDailyRateReport.AutoGenerateColumns = false; _entities = new MicroAccountsEntities1(); List <DailyRateVM> modelList = new List <DailyRateVM>(); List <DailyRate> data = new List <DailyRate>(); DateTime fromdate = DateTime.ParseExact(dateTimePicker1.Text, "dd-MM-yyyy", null); DateTime todate = DateTime.ParseExact(dateTimePicker2.Text, "dd-MM-yyyy", null); if (fromdate > todate) { MessageBox.Show("Invalid date entered. Select valid dates"); return; } else { data = _entities.DailyRates.Where(x => x.date >= fromdate && x.date <= todate).OrderByDescending(x => x.id).ToList(); foreach (var item in data) { DailyRateVM model = new DailyRateVM(); model.id = item.id; model.rowNo = rowNo; model.date = Convert.ToDateTime(item.date).Date.ToString("dd-MM-yyyy"); model.fineGold = Convert.ToDecimal(amtFormat.comma(item.fineGold)); model.twentyTwoC = Convert.ToDecimal(amtFormat.comma(item.twentyTwoC)); model.twentyThreeC = Convert.ToDecimal(amtFormat.comma(item.twentyThreeC)); model.silver = Convert.ToDecimal(amtFormat.comma(item.silver)); model.hallmark = Convert.ToDecimal(amtFormat.comma(item.hallmark)); model.hallmarkBuyBack = Convert.ToDecimal(amtFormat.comma(item.hallmarkBuyBack)); modelList.Add(model); rowNo++; } dgDailyRateReport.DataSource = modelList; } } catch (Exception x) { } }