Ejemplo n.º 1
0
        private void Btn_Generate_Click(object sender, EventArgs e)
        {
            if (LVInvoices.CheckedItems.Count <= 0)
            {
                MessageBox.Show("Please select the items for generating Invoices", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show("Are you sure, Do you want  to Generate Invoice(s)..?", "HD Magazine", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                for (int i = 0; i < LVInvoices.Items.Count; i++)
                {
                    if (LVInvoices.Items[i].Checked == true)
                    {
                        string invcode = db.GetAccCode("IN", "hdr_acc_BS_invoice", "Invoice_Code", DtpInvDt.Value);

                        string[] res = db.ExecuteQueries("Insert into mas_acc_bs_invoice values ('" + invcode + "','" + DtpInvDt.Value.ToString("dd-MMM-yy") + "','" + db.GetFinYr(DtpInvDt.Value) + "',1,0," + LVInvoices.Items[i].SubItems[1].Text.ToString() + ",'01-" + LVInvoices.Items[i].Text.ToString() + "','01-" + LVInvoices.Items[i].Text.ToString() + "'," + LVInvoices.Items[i].SubItems[11].Text.ToString() + ",null,null,null,null,null,null," + GlobalClass.UserName + "',sysdate,null,null,'I')").Split(',');
                        if (res[0].ToString() != "0")
                        {
                            MessageBox.Show("Insertion Failure..", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        res = db.ExecuteQueries("Update mas_capsulling set invoice_code='" + invcode + "' where ro_header_code='" + LVInvoices.Items[i].Text.ToString() + "' and tx_month between '01-" + DtpMnthFrm.Value.ToString("MMM-yy") + "' and '01-" + DtpMnthTo.Value.ToString("MMM-yy") + "'").Split(',');
                        if (res[0].ToString() != "0")
                        {
                            MessageBox.Show("Updation Failure..", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }
                MessageBox.Show("Successfully Generated", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadInvoices();
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (CmbRegion.Items.Count <= 0 || Convert.ToInt32(db.ExtractCode(CmbRegion.Text)) <= 0)
            {
                MessageBox.Show("Invalid Region Name", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CmbRegion.Focus();
                return;
            }

            if (CmbParty.Items.Count <= 0 || Convert.ToInt32(db.ExtractCode(CmbParty.Text)) <= 0)
            {
                MessageBox.Show("Invalid Party Name", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CmbParty.Focus();
                return;
            }

            if (CmbPayMode.Items.Count <= 0 || Convert.ToInt32(db.ExtractCode(CmbPayMode.Text)) <= 0)
            {
                MessageBox.Show("Invalid Payment Mode", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CmbPayMode.Focus();
                return;
            }

            if (CmbBank.Items.Count <= 0 || Convert.ToInt32(db.ExtractCode(CmbBank.Text)) <= 0)
            {
                MessageBox.Show("Invalid Bank Name", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CmbBank.Focus();
                return;
            }

            if (TxtAmount.Text.Length <= 0)
            {
                MessageBox.Show("Invalid Receipt Amount", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtAmount.Focus();
                return;
            }

            if (Convert.ToDouble(TxtAmount.Text) <= 0)
            {
                MessageBox.Show("Invalid Receipt Amount", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtAmount.Focus();
                return;
            }

            string rcptno = db.GetAccCode("RC", "mas_acc_receipt", "Receipt_code", DtpRcptDt.Value);

            string[] res = db.ExecuteQueries("Insert into mas_acc_receipt values ('" + rcptno + "','" + DtpRcptDt.Value.ToString("dd-MMM-yyyy") + "','" + db.GetFinYr(DtpRcptDt.Value) + "'," + db.ExtractCode(CmbPartyType.Text) + "," + db.ExtractCode(CmbRegion.Text) + "," + db.ExtractCode(CmbParty.Text) + "," + TxtAmount.Text.Trim() + "," + db.ExtractCode(CmbPayMode.Text) + ",'" + TxtRefNo.Text.Trim() + "','" + DtpRefDt.Value.ToString("dd-MMM-yyyy") + "'," + db.ExtractCode(CmbBank.Text) + ",'" + TxtRemarks.Text.Trim() + "','" + GlobalClass.UserName + "',sysdate, null, null, 'I')").Split(',');
            if (res[0].ToString() != "0")
            {
                MessageBox.Show("Insertion Failure..\n" + res[1].ToString(), "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            res = db.ExecuteQueries("Insert into mas_acc_reconcillation values (" + db.GetNewID("mas_acc_reconcillation", "recon_code") + ",'" + DtpRcptDt.Value.ToString("dd-MMM-yyyy") + "','" + db.GetFinYr(DtpRcptDt.Value) + "'," + db.ExtractCode(CmbPartyType.Text) + "," + db.ExtractCode(CmbParty.Text) + "," + db.ExtractCode(CmbRegion.Text) + ",'" + rcptno + "','" + DtpRcptDt.Value.ToString("dd-MMM-yyyy") + "','R'," + TxtAmount.Text.Trim() + ",null,null,'" + GlobalClass.UserName + "',sysdate, null, null, 'I')").Split(',');
            if (res[0].ToString() != "0")
            {
                MessageBox.Show("Insertion Failure..\n" + res[1].ToString(), "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                db.ExecuteQueries("Delete from mas_acc_receipt where receipt_code='" + rcptno + "'");
                return;
            }

            MessageBox.Show("Successfully Saved with Receipt No. " + rcptno, "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Information);
            TxtAmount.Text   = "";
            TxtRcptCode.Text = db.GetAccCode("RC", "mas_acc_receipt", "Receipt_code", DtpRcptDt.Value);
            TxtRefNo.Text    = "";
            TxtRemarks.Text  = "";
        }
        private void Btn_Generate_Click(object sender, EventArgs e)
        {
            if (LVInvoices.CheckedItems.Count <= 0)
            {
                MessageBox.Show("No RO(s) selected for generating Invoices", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (MessageBox.Show("Are you sure, Do you want  to Generate Invoice(s)..?", "HD Magazine", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                for (int i = 0; i < LVInvoices.Items.Count; i++)
                {
                    if (LVInvoices.Items[i].Checked == true)
                    {
                        string invcode = db.GetAccCode("IN", "Mas_acc_invoice", "Invoice_Code", DtpInvDt.Value);

                        string[] res = db.ExecuteQueries("Insert into mas_acc_invoice values ('" + invcode + "','" + DtpInvDt.Value.ToString("dd-MMM-yy") + "','" + db.GetFinYr(DtpInvDt.Value) + "'," + LVInvoices.Items[i].SubItems[12].Text.ToString() + "," + LVInvoices.Items[i].SubItems[13].Text.ToString() + "," + LVInvoices.Items[i].SubItems[11].Text.ToString() + ",'01-" + DtpMnthFrm.Value.ToString("MMM-yy") + "','01-" + DtpMnthTo.Value.ToString("MMM-yy") + "','" + LVInvoices.Items[i].Text.ToString() + "'," + LVInvoices.Items[i].SubItems[4].Text.ToString() + "," + LVInvoices.Items[i].SubItems[5].Text.ToString() + ",null," + LVInvoices.Items[i].SubItems[6].Text.ToString() + ",null," + LVInvoices.Items[i].SubItems[7].Text.ToString() + ",null," + LVInvoices.Items[i].SubItems[8].Text.ToString() + ",null," + LVInvoices.Items[i].SubItems[9].Text.ToString() + "," + LVInvoices.Items[i].SubItems[10].Text.ToString() + ",'" + DtpInvDt.Value.ToString("dd-MMM-yy") + "', null,null,null,null,'" + GlobalClass.UserName + "',sysdate,null,null,'I')").Split(',');
                        if (res[0].ToString() != "0")
                        {
                            MessageBox.Show("Insertion Failure..", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        res = db.ExecuteQueries("Update mas_capsulling set invoice_code='" + invcode + "' where invoice_code is null and ro_header_code='" + LVInvoices.Items[i].Text.ToString() + "' and tx_month between '01-" + DtpMnthFrm.Value.ToString("MMM-yy") + "' and '01-" + DtpMnthTo.Value.ToString("MMM-yy") + "'").Split(',');
                        if (res[0].ToString() != "0")
                        {
                            MessageBox.Show("Updation Failure..", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }

                db.ExecuteQueries("update mas_acc_invoice mai set billing_frm=(select min(tx_month) from mas_capsulling where invoice_code=mai.invoice_code), billing_to=(select max(tx_month) from mas_capsulling where invoice_code=mai.invoice_code) where invoice_date = '" + DtpInvDt.Value.ToString("dd-MMM-yyyy") + "'");

                db.ExecuteQueries("insert into c##tekdev.mas_acc_reconcillation (SELECT(SELECT MAX(RECON_CODE) FROM C##TEKDEV.MAS_ACC_RECONCILLATION)+ROWNUM RECON_CODE, INVOICE_DATE RECON_DATE, FNYR, 0 GROUP_CODE, mai.AGENCY_CODE,mai.CLIENT_CODE,  hr.REGION_CODE, invoice_code REFERENCE_CODE, invoice_date REFERENCE_DATE, 'D' TRANS_TYPE, 'I' TRANS_SUB_TYPE, null BANK_NAME, null CHEQUE_NO, null CHQ_TRX_DATE, null CREDIT_AMOUNT, amount DEBIT_AMOUNT, mai.REMARKS, 6 CHANNEL_CODE, mai.CREATED_BY, mai.CREATED_DATE, mai.modified_by, mai.modified_date, mai.ACTION_TYPE FROM MAS_ACC_INVOICE Mai, hdr_ro hr where hr.ro_header_code(+) = mai.ro_header_code and invoice_code > (SELECT MAX(INVOICE_CODE) FROM C##TEKDEV.MAS_ACC_INVOICE WHERE CHANNEL_CODE=6))");

                db.ExecuteQueries("INSERT INTO C##TEKDEV.MAS_ACC_INVOICE (select Invoice_code, invoice_date, fnyr, 0 group_code, agency_code, client_code, billing_frm, billing_to, null tx_code, null tx_date, ro_header_code, null ro_detail_code, null actual_telecast_time, gross_amount, null service_tax, null swatch_cess_tax, null kk_cess_tax, null ec_tax, null hec_tax, sgst_tax_amt sgst_tax, cgst_tax_amt cgst_tax, igst_tax_amt igst_tax, discount, misc_amount, amount, receipt_amt receipt_amount, due_date, cn_amount, dn_amount, null duration, null sector4, null invoice_status, null last_posted_date, remarks, 6 channel_code, created_by, created_date, modified_by, modified_date, action_type from mas_acc_invoice where invoice_code > (SELECT MAX(INVOICE_CODE) FROM C##TEKDEV.MAS_ACC_INVOICE WHERE CHANNEL_CODE=6))");

                db.ExecuteQueries("INSERT INTO C##TEKDEV.HDR_RO (SELECT RO_HEADER_CODE, RO_DATE, 0 GROUP_CODE, AGENCY_CODE, CLIENT_CODE, SALES_PERSON_CODE, REGION_CODE, 0 CITY_CODE, NULL DEAL_CODE, NULL PROPOSAL_CODE, NULL TYPE_OF_RO, AD_CATEGORY_CODE, NULL RATE_CARD_CATEGORY, NULL GOVT_GEN_FLAG, CLIENT_REFERENCE_CODE, CLIENT_REFERENCE_DATE, BILLING_MODE, 'N' AUDIT_STATUS, 0 EVENT_ID, IS_INCLUDE_TAX, IS_COMBO, REMARKS, 6 CHANNEL_CODE, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE, ACTION_TYPE  FROM HDR_RO WHERE RO_HEADER_CODE NOT IN(SELECT RO_HEADER_CODE FROM C##TEKDEV.HDR_RO WHERE CHANNEL_CODE=6))");

                MessageBox.Show("Successfully Generated", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadInvoices();
            }
        }