private void dgSalesItem_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                btnCreate.Enabled   = false;
                lblBtnError.Visible = true;

                if (dgSalesItem.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)
                    {
                        // int id = Convert.ToInt32(dgPurchaseItem.CurrentRow.Index);

                        foreach (DataGridViewCell oneCell in dgSalesItem.SelectedCells)
                        {
                            var dgWeight = Convert.ToDecimal(dgSalesItem.Rows[oneCell.RowIndex].Cells[3].Value);
                            var dgKarat  = Convert.ToDecimal(dgSalesItem.Rows[oneCell.RowIndex].Cells[5].Value);
                            var dgMaking = Convert.ToDecimal(dgSalesItem.Rows[oneCell.RowIndex].Cells[7].Value);
                            var dgRate   = Convert.ToDecimal(dgSalesItem.Rows[oneCell.RowIndex].Cells[8].Value);


                            ttlWeight = ttlWeight - dgWeight;
                            ttlMaking = ttlMaking - dgMaking;
                            ttlKarat  = ttlKarat - dgKarat;
                            ttlRate   = ttlRate - dgRate;

                            txtTotalMaking.Text = ttlMaking.ToString();
                            txtTotalKarat.Text  = ttlKarat.ToString();
                            txtTotalRate.Text   = amtFormat.comma(ttlRate).ToString();
                            double kg = Convert.ToDouble(ttlWeight) / 1000;
                            if (kg > 0)
                            {
                                txtTotalWeight.Text = kg.ToString();
                                lblUnit.Text        = "Kg";
                            }
                            else
                            {
                                txtTotalWeight.Text = ttlWeight.ToString();
                                lblUnit.Text        = "Gram";
                            }

                            if (oneCell.Selected)
                            {
                                dgSalesItem.Rows.RemoveAt(oneCell.RowIndex);
                            }

                            txtAmtInWords.Text = "";
                            ConvertNoToWord convertToWord = new ConvertNoToWord();
                            txtAmtInWords.Text = convertToWord.ConvertNumbertoWords(Convert.ToInt32(ttlRate)).ToLower();
                        }
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("Something went wrong. Contact your system administrator");
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        private void showAvailableData()
        {
            clear();
            clearDetails();

            btnCreate.Text = "Update";
            _entities      = new KBBQEntities();

            var data = _entities.tbl_PurchaseMaster.Where(x => x.pId == passedPid).FirstOrDefault();

            txtRefNo.Text     = data.refNo;
            dateToday.Text    = data.date.ToString();
            txtRemark.Text    = data.remarks.ToString();
            txtPartyName.Text = data.partyName.Trim().ToString();

            txtTotalAmt.Text    = amtFormat.comma(data.totalAmt).ToString();
            txtTotalWeight.Text = data.totalWeight.ToString();

            ttlWeight = Convert.ToDecimal(txtTotalWeight.Text) * 1000;
            ttlRate   = Convert.ToDecimal(txtTotalAmt.Text);


            txtAmtInWords.Text = "";
            ConvertNoToWord convertToWord = new ConvertNoToWord();

            //int totalRate = Convert.ToInt32(txtTotalRate.Text);
            txtAmtInWords.Text = convertToWord.ConvertNumbertoWords(Convert.ToInt32(data.totalAmt)).ToLower();

            _entities = new KBBQEntities();

            var purchaseDetailsData = _entities.tbl_PurchaseDetails.Where(x => x.purchaseID == passedPid).ToList();

            id = 1;
            foreach (var item in purchaseDetailsData)
            {
                var pName = _entities.purchaseProducts.Where(x => x.id == item.productID).FirstOrDefault().pName;

                dgPurchaseItem.Rows.Add(
                    id.ToString(),
                    pName,
                    item.qty,
                    item.weight,
                    item.unit,
                    item.rate);

                id = id + 1;
            }
        }
Exemple #4
0
        private void txtRate_Leave(object sender, EventArgs e)
        {
            try
            {
                btnCreate.Enabled   = true;
                lblBtnError.Visible = false;

                if (txtitemName.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtitemName, "Enter item Code.");
                    txtitemName.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter item code.";
                }
                else if (txtQty.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtQty, "Enter Qty.");
                    txtQty.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Qty.";
                }
                else if (txtWeight.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtWeight, "Enter item weight.");
                    txtWeight.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter item weight.";
                }


                else if (txtRate.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtRate, "Enter rate.");
                    txtRate.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter rate.";
                }

                else
                {
                    errorProvider1.Clear();

                    if (txtitemName.Text != string.Empty && txtQty.Text != string.Empty && txtWeight.Text != string.Empty && txtRate.Text != string.Empty)
                    {
                        if (datagridEdit)
                        {
                            //  MessageBox.Show( dgPurchaseItem.Rows[datagridId].Cells);
                            dgPurchaseItem.Rows[datagridId].Cells[1].Value = txtitemName.Text;
                            dgPurchaseItem.Rows[datagridId].Cells[2].Value = txtQty.Text;
                            dgPurchaseItem.Rows[datagridId].Cells[3].Value = txtWeight.Text;
                            dgPurchaseItem.Rows[datagridId].Cells[4].Value = comboUnit.Text;
                            dgPurchaseItem.Rows[datagridId].Cells[5].Value = txtRate.Text;

                            this.datagridEdit = false;

                            var dgQty    = Convert.ToDecimal(dgPurchaseItem.Rows[datagridId].Cells[2].Value);
                            var dgWeight = Convert.ToDecimal(dgPurchaseItem.Rows[datagridId].Cells[3].Value);
                            var dgrate   = Convert.ToDecimal(dgPurchaseItem.Rows[datagridId].Cells[5].Value);
                        }
                        else
                        {
                            dgPurchaseItem.Rows.Add(id.ToString(), txtitemName.Text, txtQty.Text, txtWeight.Text, comboUnit.Text, txtRate.Text);
                            //dgPurchaseOrderDetails.Rows.Add(id.ToString(), txtitemName.Text, "harsh", "200", "G", "500");
                            //dgPurchaseItem.Rows.Add(id.ToString(), txtitemName.Text, "harsh", "200", "G", "500");
                            id = id + 1;
                        }


                        if (comboUnit.Text == "Kg")
                        {
                            decimal grams = Convert.ToDecimal(txtWeight.Text) * 1000;
                            ttlWeight = ttlWeight + grams;
                        }
                        else
                        {
                            ttlWeight = ttlWeight + Convert.ToDecimal(txtWeight.Text);
                        }

                        ttlRate = ttlRate + Convert.ToDecimal(txtRate.Text);
                    }


                    double kg = Convert.ToDouble(ttlWeight) / 1000;
                    if (kg > 0)
                    {
                        txtTotalWeight.Text = kg.ToString();
                        lblUnit.Text        = "Kg";
                    }
                    else
                    {
                        txtTotalWeight.Text = ttlWeight.ToString();
                        lblUnit.Text        = "Gram";
                    }
                    txtTotalAmt.Text = amtFormat.comma(ttlRate).ToString();

                    clearDetails();
                    txtitemName.Focus();
                    errorProvider1.Clear();

                    txtAmtInWords.Text = "";
                    ConvertNoToWord convertToWord = new ConvertNoToWord();
                    var             rats          = Convert.ToDecimal(txtTotalAmt.Text.Trim().ToString());
                    txtAmtInWords.Text = convertToWord.ConvertNumbertoWords(Convert.ToInt32(rats)).ToLower();
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("Something went wrong. Contact your system administrator");
            }
        }
        private void showAvailData()
        {
            clear();
            clearDetails();

            btnCreate.Text = "Update";
            _entities      = new MicroAccountsEntities1();

            var data = _entities.tbl_SalesMaster.Where(x => x.sId == passedSid).FirstOrDefault();

            txtBillNo.Text       = data.billNo;
            dateTimePicker1.Text = data.date.ToString();
            txtLedgerName.Text   = _entities.tbl_AccLedger.Where(x => x.Id == data.ledgerId).FirstOrDefault().ledgerName;

            txtTotalKarat.Text  = data.totalKarat.ToString();
            txtTotalMaking.Text = amtFormat.comma(data.totalMaking).ToString();
            txtTotalRate.Text   = amtFormat.comma(data.totalAmt).ToString();
            txtTotalWeight.Text = data.totalWeight.ToString();

            ttlWeight = Convert.ToDecimal(txtTotalWeight.Text) * 1000;
            ttlKarat  = Convert.ToDecimal(txtTotalKarat.Text);
            ttlRate   = Convert.ToDecimal(txtTotalRate.Text);
            ttlMaking = Convert.ToDecimal(txtTotalMaking.Text);

            txtAmtInWords.Text = "";
            ConvertNoToWord convertToWord = new ConvertNoToWord();

            //int totalRate = Convert.ToInt32(txtTotalRate.Text);
            txtAmtInWords.Text = convertToWord.ConvertNumbertoWords(Convert.ToInt32(data.totalAmt)).ToLower();

            _entities = new MicroAccountsEntities1();

            var salesDetailsData = _entities.tbl_SalesDetails.Where(x => x.salesId == passedSid).ToList();

            id = 1;
            foreach (var item in salesDetailsData)
            {
                var itemCode = _entities.tbl_ItemMaster.Where(x => x.id == item.productId).FirstOrDefault().itemCode;

                dgSalesItem.Rows.Add(
                    id.ToString(),
                    itemCode,
                    item.qty,
                    item.weight,
                    item.unit,
                    item.karat,
                    item.kRate,
                    item.making,
                    item.rate);

                id = id + 1;
            }

            var checkLedgername = _entities.tbl_AccLedger.Where(x => x.ledgerName == txtLedgerName.Text.Trim().ToString()).FirstOrDefault();

            decimal drLedgerId = Convert.ToDecimal(checkLedgername.Id);

            CrDrDifference crdrDiff = new CrDrDifference();
            string         valueAmt = crdrDiff.DifferenceCrDr(Convert.ToInt32(drLedgerId), 0);

            lblBalance.Text = valueAmt;
        }
        private void txtRate_Leave(object sender, EventArgs e)
        {
            try
            {
                btnCreate.Enabled   = true;
                lblBtnError.Visible = false;

                if (txtItemCode.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtItemCode, "Enter item Code.");
                    txtItemCode.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter item code.";
                }
                else if (txtQty.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtQty, "Enter qty.");
                    txtQty.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter qty.";
                }
                else if (txtWeight.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtWeight, "Enter item weight.");
                    txtWeight.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter item weight.";
                }
                //else if (cmbKarat.SelectedIndex == 0 || cmbKarat.Text == string.Empty)
                //{
                //    errorProvider1.Clear();
                //    errorProvider1.SetError(cmbKarat, "Enter karat.");
                //    cmbKarat.Focus();
                //    panel3.Visible = true;
                //    lblError.Text = "Enter karat.";
                //}

                else if (txtKRate.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtKRate, "Enter karat Rate.");
                    txtKRate.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter karat Rate.";
                }

                else if (txtMaking.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtMaking, "Enter making.");
                    txtMaking.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter making.";
                }

                else if (txtRate.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtRate, "Enter rate.");
                    txtRate.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter rate.";
                }

                else
                {
                    errorProvider1.Clear();

                    if (txtItemCode.Text != string.Empty && txtQty.Text != string.Empty && txtWeight.Text != string.Empty && cmbKarat.Text != string.Empty && txtMaking.Text != string.Empty && txtRate.Text != string.Empty)
                    {
                        if (datagridEdit)
                        {
                            //  MessageBox.Show( dgPurchaseItem.Rows[datagridId].Cells);
                            dgSalesItem.Rows[datagridId].Cells[1].Value = txtItemCode.Text;
                            dgSalesItem.Rows[datagridId].Cells[2].Value = txtQty.Text;
                            dgSalesItem.Rows[datagridId].Cells[3].Value = txtWeight.Text;
                            dgSalesItem.Rows[datagridId].Cells[4].Value = cmbUnit.Text;

                            if (cmbKarat.SelectedIndex == 0)
                            {
                                dgSalesItem.Rows[datagridId].Cells[5].Value = 0;
                            }
                            else
                            {
                                dgSalesItem.Rows[datagridId].Cells[5].Value = cmbKarat.Text;
                            }

                            dgSalesItem.Rows[datagridId].Cells[6].Value = txtKRate.Text;
                            dgSalesItem.Rows[datagridId].Cells[7].Value = txtMaking.Text;
                            dgSalesItem.Rows[datagridId].Cells[8].Value = txtRate.Text;

                            this.datagridEdit = false;

                            var dgWeight  = Convert.ToDecimal(dgSalesItem.Rows[datagridId].Cells[3].Value);
                            var dgMelting = Convert.ToDecimal(dgSalesItem.Rows[datagridId].Cells[5].Value);
                            var dgmaking  = Convert.ToDecimal(dgSalesItem.Rows[datagridId].Cells[7].Value);
                            var dgrate    = Convert.ToDecimal(dgSalesItem.Rows[datagridId].Cells[8].Value);
                        }
                        else
                        {
                            var kartType = "";

                            if (cmbKarat.SelectedIndex == 0)
                            {
                                kartType = "0";
                            }
                            else
                            {
                                kartType = cmbKarat.Text;
                            }

                            dgSalesItem.Rows.Add(id.ToString(), txtItemCode.Text, txtQty.Text, txtWeight.Text, cmbUnit.Text, kartType, txtKRate.Text, txtMaking.Text, txtRate.Text);
                            id = id + 1;
                        }

                        ttlMaking += Convert.ToDecimal(txtMaking.Text);
                        //ttlKarat += Convert.ToDecimal(cmbKarat.Text);

                        if (cmbUnit.Text == "Kg")
                        {
                            decimal grams = Convert.ToDecimal(txtWeight.Text) * 1000;
                            ttlWeight = ttlWeight + grams;
                        }
                        else
                        {
                            ttlWeight = ttlWeight + Convert.ToDecimal(txtWeight.Text);
                        }

                        ttlRate = ttlRate + Convert.ToDecimal(txtRate.Text);
                    }

                    txtTotalMaking.Text = ttlMaking.ToString();
                    //txtTotalKarat.Text = ttlKarat.ToString();

                    double kg = Convert.ToDouble(ttlWeight) / 1000;
                    if (kg > 0)
                    {
                        txtTotalWeight.Text = kg.ToString();
                        lblUnit.Text        = "Kg";
                    }
                    else
                    {
                        txtTotalWeight.Text = ttlWeight.ToString();
                        lblUnit.Text        = "Gram";
                    }
                    txtTotalRate.Text = amtFormat.comma(ttlRate).ToString();


                    clearDetails();
                    txtItemCode.Focus();
                    errorProvider1.Clear();

                    txtAmtInWords.Text = "";
                    ConvertNoToWord convertToWord = new ConvertNoToWord();
                    var             rats          = Convert.ToDecimal(txtTotalRate.Text.Trim().ToString());
                    txtAmtInWords.Text = convertToWord.ConvertNumbertoWords(Convert.ToInt32(rats)).ToLower();
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("Something went wrong. Contact your system administrator");
            }
        }
        private void SalesMaster_Load(object sender, EventArgs e)
        {
            try
            {
                dateTimePicker1.Format       = DateTimePickerFormat.Custom;
                dateTimePicker1.CustomFormat = "dd-MM-yyyy";

                clear();
                clearDetails();

                _entities = new MicroAccountsEntities1();

                var gId = _entities.tbl_AccGroup.Where(x => x.groupName == "Sundry Debtors").FirstOrDefault().groupId;

                var ledgerNameAutoComplete = _entities.tbl_AccLedger.Where(x => x.groupId == gId);
                txtLedgerName.AutoCompleteCustomSource.Clear();
                foreach (var item in ledgerNameAutoComplete)
                {
                    txtLedgerName.AutoCompleteCustomSource.Add(item.ledgerName.ToString());
                }

                _entities = new MicroAccountsEntities1();
                var itemCodeAutoComplete = _entities.tbl_ItemMaster;
                txtItemCode.AutoCompleteCustomSource.Clear();
                foreach (var item in itemCodeAutoComplete)
                {
                    txtItemCode.AutoCompleteCustomSource.Add(item.itemCode.ToString());
                }


                //Edit load

                if (passedSid != 0)
                {
                    clear();
                    clearDetails();

                    btnCreate.Text = "Update";
                    _entities      = new MicroAccountsEntities1();

                    var data = _entities.tbl_SalesMaster.Where(x => x.sId == passedSid).FirstOrDefault();

                    txtBillNo.Text       = data.billNo;
                    dateTimePicker1.Text = data.date.ToString();
                    txtLedgerName.Text   = _entities.tbl_AccLedger.Where(x => x.Id == data.ledgerId).FirstOrDefault().ledgerName;

                    txtTotalKarat.Text  = data.totalKarat.ToString();
                    txtTotalMaking.Text = data.totalMaking.ToString();
                    txtTotalRate.Text   = data.totalAmt.ToString();
                    txtTotalWeight.Text = data.totalWeight.ToString();

                    ttlWeight = Convert.ToDecimal(txtTotalWeight.Text) * 1000;
                    ttlKarat  = Convert.ToDecimal(txtTotalKarat.Text);
                    ttlRate   = Convert.ToDecimal(txtTotalRate.Text);
                    ttlMaking = Convert.ToDecimal(txtTotalMaking.Text);

                    txtAmtInWords.Text = "";
                    ConvertNoToWord convertToWord = new ConvertNoToWord();
                    //int totalRate = Convert.ToInt32(txtTotalRate.Text);
                    txtAmtInWords.Text = convertToWord.ConvertNumbertoWords(Convert.ToInt32(data.totalAmt)).ToLower();

                    _entities = new MicroAccountsEntities1();

                    var salesDetailsData = _entities.tbl_SalesDetails.Where(x => x.salesId == passedSid).ToList();

                    id = 1;
                    foreach (var item in salesDetailsData)
                    {
                        var itemCode = _entities.tbl_ItemMaster.Where(x => x.id == item.productId).FirstOrDefault().itemCode;

                        dgSalesItem.Rows.Add(
                            id.ToString(),
                            itemCode,
                            item.qty,
                            item.weight,
                            item.unit,
                            item.karat,
                            item.making,
                            item.rate);

                        id = id + 1;
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.ToString());
            }
        }