Пример #1
0
        private void ARGenerateInvoice_Load(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "ARGenerateInvoice", "", "Open");

            if (msg != "")
            {
                MessageBox.Show("ARGenerateInvoice Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                btn_Generated.Visible = false;
            }
            GeneralFunctions.LockTables("", "ARGenerateInvoice", "", "Open");
            InvoiceDT                      = new DataTable();
            sqlcon                         = new SqlConnection(GeneralFunctions.ConnectionString);
            dbAccountingProjectDS          = new dbAccountingProjectDS();
            adaptertbBatch                 = new SqlDataAdapter("Select * from Batch", sqlcon);
            adaptertbInvoices              = new SqlDataAdapter("Select * from GenerateInvoice", sqlcon);
            adaptertbGenInvoice            = new SqlDataAdapter("SELECT TOP 100 PERCENT dbo.ARtrans.TransNO AS Voucher#,dbo.Batch.BatchNo AS Batch#, dbo.ARtrans.TRANSDATE AS Invoice_Date, dbo.ARtrans.AmountLC AS Amount, dbo.ARtrans.CodeTran, dbo.ARtrans.AccountCode, dbo.ARtrans.AccountName, dbo.ARtrans.GenInv AS Invoice# FROM dbo.ARtrans INNER JOIN dbo.Batch ON dbo.ARtrans.BatchNo = dbo.Batch.BatchNo Where dbo.Batch.BatchSRC = 'AR' AND dbo.ARtrans.GenInv = 0 AND dbo.ARtrans.AmountLC >= 0 ORDER BY dbo.ARtrans.TRANSDATE", sqlcon);
            adaptertbARtrans               = new SqlDataAdapter("Select * from ARtrans", sqlcon);
            cmdBuilderInvoices             = new SqlCommandBuilder();
            cmdBuilderARtrans              = new SqlCommandBuilder();
            cmdBuilderInvoices.DataAdapter = adaptertbInvoices;
            cmdBuilderARtrans.DataAdapter  = adaptertbARtrans;
            adaptertbBatch.Fill(dbAccountingProjectDS.Batch);
            adaptertbInvoices.Fill(dbAccountingProjectDS.GenerateInvoice);
            adaptertbARtrans.Fill(dbAccountingProjectDS.ARtrans);
            adaptertbGenInvoice.Fill(InvoiceDT);
            foreach (DataGridViewColumn c in dgv.Columns)
            {
                c.SortMode = DataGridViewColumnSortMode.NotSortable;
                c.ReadOnly = true;
            }
            dgv.Columns[0].ReadOnly = false;
        }
Пример #2
0
        private static int NewBatchNo()
        {
            int           No          = 0;
            SqlConnection sqlconBatch = new SqlConnection(GeneralFunctions.ConnectionString);

            sqlconBatch.Open();
            SqlCommand getBatch = new SqlCommand("Select Max(BatchNo)+1 From Batch", sqlconBatch);

            if (getBatch.ExecuteScalar() != DBNull.Value)
            {
                No = Convert.ToInt32(getBatch.ExecuteScalar());
            }
            else
            {
                No = 1;
            }
            string msg = "new";

            while (msg != "")
            {
                msg = GeneralFunctions.CheckLockTables("Batch", "", No.ToString(), "New");
                if (msg != "")
                {
                    No = No + 1;
                }
            }
            return(No);
        }
Пример #3
0
        private void btnedit_Click(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "", "", "");

            if (msg != "")
            {
                MessageBox.Show("Can't Edit Because Other Form Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            GeneralFunctions.LockTables("All", "GeneralLadger_GeneralSetup", "", "");
            groupBox1.Enabled = true;
            groupBox2.Enabled = true;
            btnedit.Visible   = false;
            btnOk.Visible     = true;
        }
Пример #4
0
        private void btnedit_Click(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("GLProjectCodes", "ProjectCodes", txt_ProjectCodeID.Text, "Edit");

            if (msg != "")
            {
                MessageBox.Show("Can't Edit This Project Because Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            GeneralFunctions.LockTables("GLProjectCodes", "ProjectCodes", txt_ProjectCodeID.Text, "Edit");

            GB1.Enabled         = true;
            btnedit.Visible     = false;
            Btnsaveedit.Visible = true;
            btn_New.Enabled     = false;
            btnDelete.Enabled   = false;
        }
Пример #5
0
        private void btn_New_Click(object sender, EventArgs e)
        {
            ClearAll();
            SqlConnection sqlcon3 = new SqlConnection(GeneralFunctions.ConnectionString);

            sqlcon3.Open();
            SqlCommand GetProjectCodeID = new SqlCommand("Select MAX(ProjectCodeID)+1 From GLProjectCodes", sqlcon3);

            if (GetProjectCodeID.ExecuteScalar() != DBNull.Value)
            {
                GeneralFunctions.ProjectCodeID = Convert.ToInt32(GetProjectCodeID.ExecuteScalar());
            }
            else
            {
                GeneralFunctions.ProjectCodeID = 1;
            }
            string msg = "new";

            while (msg != "")
            {
                msg = GeneralFunctions.CheckLockTables("GLProjectCodes", "", GeneralFunctions.ProjectCodeID.ToString(), "New");
                if (msg != "")
                {
                    GeneralFunctions.ProjectCodeID = GeneralFunctions.ProjectCodeID + 1;
                }
            }
            GeneralFunctions.LockTables("GLProjectCodes", "ProjectCodes", GeneralFunctions.ProjectCodeID.ToString(), "New");

            currentProjectCodeID   = GeneralFunctions.ProjectCodeID;
            txt_ProjectCodeID.Text = currentProjectCodeID.ToString();
            GB1.Enabled            = true;
            btn_New.Visible        = false;
            btnSavenew.Visible     = true;
            btnedit.Enabled        = false;
            btnDelete.Enabled      = false;
        }
Пример #6
0
        private void AccountsPayableControl_Load(object sender, EventArgs e)
        {
            try
            {
                string msg = GeneralFunctions.CheckLockTables("", "", "", "");
                if (msg != "")
                {
                    MessageBox.Show("Can't Open Because Other Form Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
                GeneralFunctions.LockTables("All", "AccountsPayableControl", "", "");

                dbAccountingProjectDS = new dbAccountingProjectDS();
                sqlcon = new SqlConnection(GeneralFunctions.ConnectionString);
                adapterPaymentTerms = new SqlDataAdapter("Select * from APPaymentTerms", sqlcon);
                adapterPaymentTerms.Fill(dbAccountingProjectDS.APPaymentTerms);

                cb_VendorTerms = GeneralFunctions.FillComboBox(dbAccountingProjectDS.APPaymentTerms, cb_VendorTerms, "PaymentTermCode", "PaymentTermCodeID");
                SqlConnection sqlcon10 = new SqlConnection(GeneralFunctions.ConnectionString);
                sqlcon10.Open();
                if (!GeneralFunctions.SubTypesloaded)
                {
                    SqlCommand command10 = new SqlCommand("Select AccountSubType From  GeneralSetup", sqlcon10);
                    SqlCommand command11 = new SqlCommand("Select FirstSub From GeneralSetup", sqlcon10);
                    SqlCommand command12 = new SqlCommand("Select SecondSub From GeneralSetup", sqlcon10);
                    SqlCommand command13 = new SqlCommand("Select ThirdSub From GeneralSetup", sqlcon10);
                    SqlCommand command14 = new SqlCommand("Select FourthSub From GeneralSetup", sqlcon10);
                    int        AccountSubTypeNumber;
                    if (command10.ExecuteScalar() != DBNull.Value)
                    {
                        AccountSubTypeNumber = Convert.ToInt32(command10.ExecuteScalar());
                        if (AccountSubTypeNumber == 2)
                        {
                            GeneralFunctions.LoadSubtypes(Convert.ToInt32(command11.ExecuteScalar()), Convert.ToInt32(command12.ExecuteScalar()));
                            GeneralFunctions.SubTypesloaded = true;
                        }
                        if (AccountSubTypeNumber == 3)
                        {
                            GeneralFunctions.LoadSubtypes(Convert.ToInt32(command11.ExecuteScalar()), Convert.ToInt32(command12.ExecuteScalar()), Convert.ToInt32(command13.ExecuteScalar()));
                            GeneralFunctions.SubTypesloaded = true;
                        }
                        if (AccountSubTypeNumber == 4)
                        {
                            GeneralFunctions.LoadSubtypes(Convert.ToInt32(command11.ExecuteScalar()), Convert.ToInt32(command12.ExecuteScalar()), Convert.ToInt32(command13.ExecuteScalar()), Convert.ToInt32(command14.ExecuteScalar()));
                            GeneralFunctions.SubTypesloaded = true;
                        }
                    }
                }
                fillData(sqlcon10);
                if (GeneralFunctions.languagechioce != "")
                {
                    this.obj_options = new ClassOptions();
                    this.obj_options.report_language = GeneralFunctions.languagechioce;
                    this.update_language_interface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "system Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #7
0
        private void Allocation_Run_Load(object sender, EventArgs e)
        {
            try
            {
                string msg = GeneralFunctions.CheckLockTables("", "AllocationMaintenance", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("Can't Open Because AllocationMaintenance Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
                msg = GeneralFunctions.CheckLockTables("", "Allocation Run", "", "Open");
                if (msg != "")
                {
                    MessageBox.Show("Allocation Run Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    Lock67.Visible = false;
                }
                msg = GeneralFunctions.CheckLockTables("GLFiscalPeriod", "EndMonth", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("EndMonth Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
                msg = GeneralFunctions.CheckLockTables("GLFiscalPeriodSetup", "ENDYear", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("ENDYear Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
                GeneralFunctions.LockTables("", "Allocation Run", "", "Open");
                GeneralFunctions.priviledgeGroupBox(Lock67);
                sqlcon = new SqlConnection(GeneralFunctions.ConnectionString);
                dbAccountingProjectDS     = new dbAccountingProjectDS();
                adaptertbAllocation       = new SqlDataAdapter("Select distinct(AllocationCode) from GLAllocation", sqlcon);
                adaptertbAllocationsource = new SqlDataAdapter("Select * from GLAllocation", sqlcon);
                adaptertbAllocationDestinationAccounts = new SqlDataAdapter("Select * from GLAllocationDestinationAccounts", sqlcon);
                adaptertbGLTotals         = new SqlDataAdapter("Select * from GLTotals", sqlcon);
                adaptertbGLJVTransaction  = new SqlDataAdapter("Select * From GLTransactions", sqlcon);
                adaptertbBatch            = new SqlDataAdapter("Select * From Batch", sqlcon);
                adaptertbGeneralSetup     = new SqlDataAdapter("Select * from GeneralSetup", sqlcon);
                adaptertbG_L_GeneralSetup = new SqlDataAdapter("Select * from G_L_GeneralSetup", sqlcon);
                adaptertbAccounts         = new SqlDataAdapter("Select * from GLAccounts", sqlcon);
                adaptertbAccounts.Fill(dbAccountingProjectDS.GLAccounts);
                adaptertbBatch.Fill(dbAccountingProjectDS.Batch);
                adaptertbGLTotals.Fill(dbAccountingProjectDS.GLTotals);
                adaptertbGLJVTransaction.Fill(dbAccountingProjectDS.GLTransactions);
                adaptertbAllocationsource.Fill(dbAccountingProjectDS.GLAllocation);
                adaptertbAllocationDestinationAccounts.Fill(dbAccountingProjectDS.GLAllocationDestinationAccounts);
                adaptertbG_L_GeneralSetup.Fill(dbAccountingProjectDS.G_L_GeneralSetup);
                cmdBuilderBatch           = new SqlCommandBuilder(adaptertbBatch);
                cmdBuildertbJVTransaction = new SqlCommandBuilder(adaptertbGLJVTransaction);
                cmdBuilderGLTotals        = new SqlCommandBuilder(adaptertbGLTotals);
                adaptertbGeneralSetup.Fill(dbAccountingProjectDS.GeneralSetup);
                //adaptertbG_L_GeneralSetup.Fill(dbAccountingProjectDS.G_L_GeneralSetup);
                foreach (DataRow drg in dbAccountingProjectDS.GeneralSetup.Rows)
                {
                    decmal = int.Parse(drg["DecimalPointsNumber"].ToString());
                    GeneralFunctions.JVNumberFormat = drg["JVNumberFormat"].ToString();
                    GeneralFunctions.lblJV          = drg["lblJV"].ToString();
                }
                DataRow[] drGL = dbAccountingProjectDS.G_L_GeneralSetup.Select();
                if (drGL.Length != 0)
                {
                    DefaultACCBalanceSheet   = drGL[0]["BalanceSheet"].ToString();
                    DefaultACCIncomeStatment = drGL[0]["IncomeStatment"].ToString();
                    if (DefaultACCBalanceSheet == "" || DefaultACCIncomeStatment == "")
                    {
                        MessageBox.Show("Please Check AccountBalanceSheet And AccountIncomeStatment In G/L GeneralSetup ", "Error");
                        this.Close();
                    }
                }
                dtallocation = new DataTable();
                adaptertbAllocation.Fill(dtallocation);
                ArrayList allcode = new ArrayList();
                for (int i = 0; i < dtallocation.Rows.Count; i++)
                {
                    allcode.Add(dtallocation.Rows[i][0].ToString());
                }
                adaptertbAllocation = new SqlDataAdapter("Select * from GLAllocation", sqlcon);
                adaptertbAllocation.Fill(dbAccountingProjectDS.GLAllocation);
                dtallocation = new DataTable();
                dtallocation.Columns.Add("Code", System.Type.GetType("System.String"));
                dtallocation.Columns.Add("Journal", System.Type.GetType("System.String"));
                dtallocation.Columns.Add("Description", System.Type.GetType("System.String"));
                dtallocation.Columns.Add("Repeat", System.Type.GetType("System.String"));
                DataRow   dr;
                DataRow[] drs;
                for (int i = 0; i < allcode.Count; i++)
                {
                    drs = dbAccountingProjectDS.GLAllocation.Select("AllocationCode = '" + allcode[i].ToString() + "'");
                    if (drs.Length != 0)
                    {
                        dr                = dtallocation.NewRow();
                        dr["Code"]        = drs[0]["AllocationCode"];
                        dr["Journal"]     = drs[0]["AllocationGLJournalCode"];
                        dr["Description"] = drs[0]["AllocationDescription"];
                        dr["Repeat"]      = drs[0]["AllocationRepeat"];
                        dtallocation.Rows.Add(dr);
                    }
                }

                dgvallocation.DataSource = dtallocation;
                dgvallocation.Columns["Repeat"].Visible = false;
                dgvallocation.Refresh();
                //AllocationCode,DestinationGLAccountNumber,DestinationAccountDescription,DestinationAccountPercentage
                dtSourceAccounts = new DataTable();
                //dtSourceAccounts.Columns.Add("AllocationCode", System.Type.GetType("System.Int32"));
                //dtSourceAccounts.Columns.Add("AllocationGLJournalCode", System.Type.GetType("System.String"));
                //dtSourceAccounts.Columns.Add("AllocationDescription", System.Type.GetType("System.String"));
                dtSourceAccounts.Columns.Add("AllocationSourceAccount", System.Type.GetType("System.String"));
                dtSourceAccounts.Columns.Add("AllocationSourceAccountName", System.Type.GetType("System.String"));
                dtSourceAccounts.Columns.Add("AllocationSourceAccountPercentage", System.Type.GetType("System.Double"));
                //adaptertbAllocationsource.Fill(dtSourceAccounts);
                dgvsource.DataSource = dtSourceAccounts;
                //dgvsource.Columns[0].HeaderText = "Code";
                //dgvsource.Columns[1].HeaderText = "GLJournalCode";
                //dgvsource.Columns[2].HeaderText = "Description";
                dgvsource.Columns[0].HeaderText = "AccountNumber";
                dgvsource.Columns[1].HeaderText = "AccountName";
                dgvsource.Columns[2].HeaderText = "Percentage";
                dgvsource.Refresh();
                dtDestinationAccounts = new DataTable();
                //dtDestinationAccounts.Columns.Add("AllocationCode", System.Type.GetType("System.Int32"));
                dtDestinationAccounts.Columns.Add("DestinationGLAccountNumber", System.Type.GetType("System.String"));
                dtDestinationAccounts.Columns.Add("DestinationAccountDescription", System.Type.GetType("System.String"));
                dtDestinationAccounts.Columns.Add("DestinationAccountPercentage", System.Type.GetType("System.Double"));
                //adaptertbAllocationDestinationAccounts.Fill(dtDestinationAccounts);
                dgvdestination.DataSource = dtDestinationAccounts;
                //dgvdestination.Columns[0].HeaderText = "Code";
                dgvdestination.Columns[0].HeaderText = "AccountNumber";
                dgvdestination.Columns[1].HeaderText = "AccountName";
                dgvdestination.Columns[2].HeaderText = "Percentage";
                dgvdestination.Refresh();
                if (GeneralFunctions.languagechioce != "")
                {
                    this.obj_options = new ClassOptions();
                    this.obj_options.report_language = GeneralFunctions.languagechioce;
                    this.update_language_interface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "General Ledger");
            }
        }
Пример #8
0
        private void btnrun_Click(object sender, EventArgs e)
        {
            try
            {
                string msg = GeneralFunctions.CheckLockTables("GLTotals", "", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("Can't Run Because GLTotals Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
                GeneralFunctions.LockTables("GLTotals", "Allocation Run", "", "Edit");
                if (checkvaluePercentage() == false && chkpost.Checked == true)
                {
                    MessageBox.Show("Can't Run Allocation In Status Posted Because Percentage Source Value = 0  ", "General Ledger");
                    return;
                }
                double value      = 0;
                string prdbalance = "";
                string s          = string.Format(GeneralFunctions.Format_Date, DateTime.Now);
                prdbalance      = FindPeriod(s);
                currentJVNumber = GeneralFunctions.CreateJVNumberFormat(GeneralFunctions.lblJV, GeneralFunctions.JVNumberFormat, true);
                if (GeneralFunctions.RetrievePeriod(string.Format(GeneralFunctions.Format_Date, DateTime.Now), out currentPeriodID, out periodName, out currentEndDate))
                {
                }
                else
                {
                    MessageBox.Show("The period has been defined", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (dgvallocation.CurrentRow.Cells["Repeat"].Value.ToString() == "0")
                {
                    DataRow[] drc = dbAccountingProjectDS.Batch.Select("AllocationCode = '" + dgvallocation.CurrentRow.Cells["Code"].Value.ToString() + "' AND BatchPRD = '" + periodName + "'");
                    if (drc.Length != 0)
                    {
                        MessageBox.Show("Can't Run This Allocation In This Period Again", "General Ledger");
                        return;
                    }
                }
                SqlConnection sqlconBatch = new SqlConnection(GeneralFunctions.ConnectionString);
                sqlconBatch.Open();
                SqlCommand getBatch = new SqlCommand("Select Max(BatchNo)+1 From Batch", sqlconBatch);

                if (getBatch.ExecuteScalar() != DBNull.Value)
                {
                    NewNumber = Convert.ToInt32(getBatch.ExecuteScalar());
                }
                else
                {
                    NewNumber = 1;
                }
                sqlconBatch.Close();
                msg = "new";
                while (msg != "")
                {
                    msg = GeneralFunctions.CheckLockTables("Batch", "", NewNumber.ToString(), "New");
                    if (msg != "")
                    {
                        NewNumber = NewNumber + 1;
                    }
                }
                GeneralFunctions.LockTables("Batch", "Allocation Run", NewNumber.ToString(), "New");
                sqlconBatch.Open();
                SqlCommand    cmdBatchSelect = new SqlCommand("Select BatchNo From Batch Where BatchNo=" + NewNumber + "", sqlconBatch);
                SqlDataReader drBatch        = cmdBatchSelect.ExecuteReader();
                if (!drBatch.HasRows && !GeneralFunctions.FindRow("BatchNo=" + NewNumber + "", dbAccountingProjectDS.Batch))
                {
                    DataRow rBatch = this.dbAccountingProjectDS.Batch.NewRow();
                    rBatch["BatchNo"]   = NewNumber;
                    rBatch["JVNumber"]  = currentJVNumber;
                    rBatch["BatchDate"] = DateTime.Now.Date; //string.Format(GeneralFunctions.Format_Date, DTP_JVDate.Value.Date);
                    rBatch["BatchPRD"]  = periodName;
                    rBatch["BatchDSC"]  = dgvallocation.CurrentRow.Cells["Description"].Value.ToString();
                    rBatch["BatchSRC"]  = "GL";
                    rBatch["BatchJNL"]  = dgvallocation.CurrentRow.Cells["Journal"].Value.ToString();
                    if (chkpost.Checked == true)
                    {
                        rBatch["BatchStat"] = "P";
                    }
                    else if (chkpost.Checked == false)
                    {
                        rBatch["BatchStat"] = "U";
                    }
                    rBatch["PostDate"]       = DateTime.Now.Date;
                    rBatch["UserID"]         = AaDeclrationClass.xUserCode.ToString();
                    rBatch["REVBatch"]       = 0;
                    rBatch["REVBatchNo"]     = 0;
                    rBatch["REVBatchPRD"]    = "";
                    rBatch["AllocationCode"] = dgvallocation.CurrentRow.Cells[0].Value.ToString();
                    rBatch["PropertyCode"]   = "";
                    rBatch["Tran_Cashier"]   = false;
                    dbAccountingProjectDS.Batch.Rows.Add(rBatch);
                    drBatch.Close();
                    sqlconBatch.Close();
                    SqlConnection sqlTransactions = new SqlConnection(GeneralFunctions.ConnectionString);
                    sqlTransactions.Open();
                    double totalsource = 0;
                    int    sort        = 1;
                    if (chkpost.Checked == true)
                    {
                        if (CheckBalanceAccType() != false)
                        {
                            AddAccountsForBS_PL(NewNumber, prdbalance);
                        }
                    }
                    for (int i = 0; i < dtSourceAccounts.Rows.Count; i++)
                    {
                        r = dtSourceAccounts.Rows[i];
                        if (r.Equals(dtSourceAccounts.Rows[dtSourceAccounts.Rows.Count - 1]) && r["AllocationSourceAccount"].ToString() == "" && r["AllocationSourceAccountName"].ToString() == "")
                        {
                            break;
                        }
                        if (r.RowState == DataRowState.Added || r.RowState == DataRowState.Modified)
                        {
                            Valuesource = CurrentBalanceAccount(prdbalance, dtSourceAccounts.Rows[i]["AllocationSourceAccount"].ToString(), DateTime.Now.Date);
                            value       = (Valuesource / 100) * (double)dtSourceAccounts.Rows[i]["AllocationSourceAccountPercentage"];
                            value       = GeneralFunctions.ChangeDecimal(value, decmal);
                            value       = -1 * value;
                            r           = this.dbAccountingProjectDS.GLTransactions.NewRow();
                            SqlCommand commadTransactions = new SqlCommand("Select MAX(TransNO)+1 From GLTransactions", sqlTransactions);
                            if (commadTransactions.ExecuteScalar() != DBNull.Value)
                            {
                                r["TransNO"] = Convert.ToUInt32(commadTransactions.ExecuteScalar());
                            }
                            else
                            {
                                r["TransNO"] = 1;
                            }
                            r["BatchNo"]      = NewNumber;
                            r["GLAccount"]    = dtSourceAccounts.Rows[i]["AllocationSourceAccount"].ToString(); //txt_JVNumber.Text;
                            r["TRANSREF"]     = "";
                            r["TRANSDATE"]    = DateTime.Now.Date;
                            r["AmountLC"]     = value;
                            r["Amount"]       = 0;
                            r["TRANSUnit"]    = 0;
                            r["CurrencyType"] = "";
                            r["Rate"]         = "0";
                            r["ProjectCode"]  = "";
                            r["SortNO"]       = sort;
                            sort++;

                            dbAccountingProjectDS.GLTransactions.Rows.Add(r);
                            if (chkpost.Checked == true)
                            {
                                ModifyTotals(prdbalance, dtSourceAccounts.Rows[i]["AllocationSourceAccount"].ToString(), value, DateTime.Now.Date);
                            }
                            updatetable();//adaptertbGLTotals.Update(dbAccountingProjectDS.GLTotals);
                            dbAccountingProjectDS.AcceptChanges();
                            value       = -1 * value;
                            totalsource = totalsource + value;
                            Valuesource = 0;
                            value       = 0;
                        }
                    }
                    for (int i = 0; i < dtDestinationAccounts.Rows.Count; i++)
                    {
                        r = dtDestinationAccounts.Rows[i];
                        if (r.Equals(dtDestinationAccounts.Rows[dtDestinationAccounts.Rows.Count - 1]) && r["DestinationGLAccountNumber"].ToString() == "" && r["DestinationAccountDescription"].ToString() == "")
                        {
                            break;
                        }
                        if (r.RowState == DataRowState.Added || r.RowState == DataRowState.Modified)
                        {
                            value = (totalsource / 100) * double.Parse(dtDestinationAccounts.Rows[i]["DestinationAccountPercentage"].ToString());
                            value = GeneralFunctions.ChangeDecimal(value, decmal);
                            r     = this.dbAccountingProjectDS.GLTransactions.NewRow();
                            SqlCommand commadTransactions = new SqlCommand("Select MAX(TransNO)+1 From GLTransactions", sqlTransactions);
                            if (commadTransactions.ExecuteScalar() != DBNull.Value)
                            {
                                r["TransNO"] = Convert.ToUInt32(commadTransactions.ExecuteScalar());
                            }
                            else
                            {
                                r["TransNO"] = 1;
                            }
                            r["BatchNo"]      = NewNumber;
                            r["GLAccount"]    = dtDestinationAccounts.Rows[i]["DestinationGLAccountNumber"].ToString(); //txt_JVNumber.Text;
                            r["TRANSREF"]     = "";
                            r["TRANSDATE"]    = DateTime.Now.Date;
                            r["AmountLC"]     = value;
                            r["Amount"]       = 0;
                            r["TRANSUnit"]    = 0;
                            r["CurrencyType"] = "";
                            r["Rate"]         = "0";
                            r["ProjectCode"]  = "";
                            r["SortNO"]       = sort;
                            sort++;

                            dbAccountingProjectDS.GLTransactions.Rows.Add(r);
                            if (chkpost.Checked == true)
                            {
                                ModifyTotals(prdbalance, dtDestinationAccounts.Rows[i]["DestinationGLAccountNumber"].ToString(), value, DateTime.Now.Date);
                            }
                            updatetable();//adaptertbGLTotals.Update(dbAccountingProjectDS.GLTotals);
                            dbAccountingProjectDS.AcceptChanges();
                            value = 0;
                        }
                    }

                    totalsource = 0;
                    updatetable();
                    sqlTransactions.Close();
                    MessageBox.Show("JV Transaction Record inserted successfully");
                    lbllastran.Text = "Last Run in " + string.Format(GeneralFunctions.Format_Date, DateTime.Now.Date);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "General Ledger");
            }
            finally
            {
                GeneralFunctions.UnLockTable("", "Allocation Run", "", "New");
                GeneralFunctions.UnLockTable("", "Allocation Run", "", "Edit");
            }
        }
Пример #9
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                double Receipt_Amt = 0; double.TryParse(txtReceipt_Amt.Text, out Receipt_Amt);
                double Cash_Fees   = 0; double.TryParse(txtCash_Fees.Text, out Cash_Fees);
                double NetDeposit  = 0; double.TryParse(txt_NetDeposit.Text, out NetDeposit);

                if (cb_Bank_Deposit_Type.SelectedIndex == -1)
                {
                    MessageBox.Show("Select Bank Deposit Type", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
                if (Receipt_Amt == 0)
                {
                    MessageBox.Show("Insert Receipt Amount", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
                string msg = GeneralFunctions.CheckLockTables("GLTotals", "", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("Can't Run Because GLTotals Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                string currentBankNumber = GeneralFunctions.CreateBankNumberFormat(GeneralFunctions.lblBank, GeneralFunctions.BankNumberFormat, true);
                if (ValidateYear() && ValidatePeriod())
                {
                    int     BatchNo = NewBatchNo();
                    DataRow rBatch  = this.dbAccountingProjectDS.Batch.NewRow();
                    rBatch["BatchNo"]        = BatchNo;
                    rBatch["JVNumber"]       = currentBankNumber;
                    rBatch["BatchDate"]      = DTP_JVDate.Value.Date; //string.Format(GeneralFunctions.Format_Date, DTP_JVDate.Value.Date);
                    rBatch["BatchPRD"]       = txt_Period.Text;
                    rBatch["BatchDSC"]       = txt_JVDescription.Text;
                    rBatch["BatchSRC"]       = "Bank";
                    rBatch["BatchJNL"]       = JNL_BankDeposit;
                    rBatch["BatchStat"]      = "U";
                    rBatch["PostDate"]       = DBNull.Value;
                    rBatch["UserID"]         = AaDeclrationClass.xUserCode.ToString();
                    rBatch["REVBatch"]       = 0;
                    rBatch["REVBatchNo"]     = 0;
                    rBatch["REVBatchPRD"]    = "";
                    rBatch["PropertyCode"]   = 0;
                    rBatch["AllocationCode"] = "";
                    rBatch["Tran_Cashier"]   = true;
                    dbAccountingProjectDS.Batch.Rows.Add(rBatch);
                    DataRow r;
                    r                   = this.dbAccountingProjectDS.GLTransactions.NewRow();
                    r["TransNO"]        = NewTransNoGL();
                    r["BatchNo"]        = BatchNo;
                    r["GLAccount"]      = Lst_Bank_Deposit_Type["Bank_GL_Account"].ToString();
                    r["TRANSREF"]       = "";
                    r["TRANSDATE"]      = DTP_JVDate.Value.Date;
                    r["TRANSUnit"]      = 0;
                    r["Amount"]         = 0;
                    r["AmountLC"]       = NetDeposit;
                    r["CurrencyType"]   = "";
                    r["Rate"]           = "0";
                    r["ProjectCode"]    = "";
                    r["DepartmentCode"] = "";
                    r["SortNO"]         = 1;
                    dbAccountingProjectDS.GLTransactions.Rows.Add(r);
                    r                   = this.dbAccountingProjectDS.GLTransactions.NewRow();
                    r["TransNO"]        = NewTransNoGL();
                    r["BatchNo"]        = BatchNo;
                    r["GLAccount"]      = Lst_Bank_Deposit_Type["Acct_Deposit_From"].ToString();
                    r["TRANSREF"]       = "";
                    r["TRANSDATE"]      = DTP_JVDate.Value.Date;
                    r["TRANSUnit"]      = 0;
                    r["Amount"]         = 0;
                    r["AmountLC"]       = -1 * Receipt_Amt;
                    r["CurrencyType"]   = "";
                    r["Rate"]           = "0";
                    r["ProjectCode"]    = "";
                    r["DepartmentCode"] = "";
                    r["SortNO"]         = 2;
                    dbAccountingProjectDS.GLTransactions.Rows.Add(r);
                    if (Cash_Fees != 0)
                    {
                        r            = this.dbAccountingProjectDS.GLTransactions.NewRow();
                        r["TransNO"] = NewTransNoGL();
                        r["BatchNo"] = BatchNo;
                        if ((bool)Lst_Bank_Deposit_Type["Credit_Card_Deposit"])
                        {
                            r["GLAccount"] = Lst_Bank_Deposit_Type["CC_Discount_Acct"].ToString();
                        }
                        else
                        {
                            r["GLAccount"] = Lst_Bank_Deposit_Type["Cash_Short_Over_Acct"].ToString();
                        }
                        r["TRANSREF"]       = "";
                        r["TRANSDATE"]      = DTP_JVDate.Value.Date;
                        r["TRANSUnit"]      = 0;
                        r["Amount"]         = 0;
                        r["AmountLC"]       = -1 * Cash_Fees;
                        r["CurrencyType"]   = "";
                        r["Rate"]           = "0";
                        r["ProjectCode"]    = "";
                        r["DepartmentCode"] = "";
                        r["SortNO"]         = 3;
                        dbAccountingProjectDS.GLTransactions.Rows.Add(r);
                    }
                    string prdbalance = "";
                    double val        = 0;
                    int    NewBNo     = 0;
                    update();
                    if (CheckBalanceAccType(BatchNo) != false)
                    {
                        AddAccountsForBS_PL(BatchNo);
                    }
                    DataRow[] drbatch = this.dbAccountingProjectDS.Batch.Select("BatchNo=" + BatchNo + " AND BatchStat='U'");
                    if (drbatch.Length != 0)
                    {
                        drbatch[0]["BatchStat"] = "P";
                        drbatch[0]["PostDate"]  = DateTime.Now.ToShortDateString();
                        DataRow[] transactionArray = this.dbAccountingProjectDS.GLTransactions.Select("BatchNo=" + BatchNo + "");
                        if (transactionArray.Length != 0)
                        {
                            string st = string.Format(GeneralFunctions.Format_Date, DTP_JVDate.Value);
                            prdbalance = FindPeriod(st);
                            for (int i = 0; i < transactionArray.Length; i++)
                            {
                                DataRow[] Acctype = dbAccountingProjectDS.GLAccounts.Select("AccountNumber = '" + transactionArray[i]["GLAccount"].ToString() + "'");
                                if (Acctype.Length != 0)
                                {
                                    if (Acctype[0]["AccountTypeName"].ToString() != "Statictical")
                                    {
                                        val = double.Parse(transactionArray[i]["AmountLC"].ToString());
                                    }
                                    else
                                    {
                                        val = double.Parse(transactionArray[i]["TRANSUnit"].ToString());
                                    }
                                }
                                ModifyTotals(prdbalance, transactionArray[i]["GLAccount"].ToString(), val, Convert.ToDateTime(drbatch[0]["BatchDate"].ToString()).Date);
                            }
                        }
                    }

                    update();
                    MessageBox.Show("The given Batch is posted", "General Ledger", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #10
0
        private void ApplyCreditsScreen_Load(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "ARApplyCreditsScreen", "", "Open");

            if (msg != "")
            {
                MessageBox.Show("ARApplyCreditsScreen Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                btn_Save.Visible = false;
            }
            GeneralFunctions.LockTables("", "ARApplyCreditsScreen", "", "Open");
            sqlcon                   = new SqlConnection(GeneralFunctions.ConnectionString);
            adaptertbARCredits       = new SqlDataAdapter("Select * from ARCredits", sqlcon);
            adaptertbBatch           = new SqlDataAdapter("Select * from Batch", sqlcon);
            adaptertbBatchInvoices   = new SqlDataAdapter("Select * from ARtrans", sqlcon);
            adaptertbInvoiceAccounts = new SqlDataAdapter("Select * from APExpense", sqlcon);
            adaptertbCurrency        = new SqlDataAdapter("Select * from GLCurrency", sqlcon);

            cmdBuilder          = new SqlCommandBuilder(adaptertbBatchInvoices);
            cmdBuilderARCredits = new SqlCommandBuilder(adaptertbARCredits);

            adaptertbBatch.Fill(dbAccountingProjectDS.Batch);
            adaptertbARCredits.Fill(dbAccountingProjectDS.ARCredits);
            adaptertbBatchInvoices.Fill(dbAccountingProjectDS.ARtrans);
            adaptertbInvoiceAccounts.Fill(dbAccountingProjectDS.APExpense);
            adaptertbCurrency.Fill(dbAccountingProjectDS.GLCurrency);
            adaptertbGeneralSetup = new SqlDataAdapter("Select * from GeneralSetup", sqlcon);
            adaptertbGeneralSetup.Fill(dbAccountingProjectDS.GeneralSetup);
            foreach (DataRow dr in dbAccountingProjectDS.GeneralSetup.Rows)
            {
                decmal = int.Parse(dr["DecimalPointsNumber"].ToString());
            }
            DataRow[] drbatch   = dbAccountingProjectDS.Batch.Select("BatchSRC = 'ARP' AND BatchStat = 'P'");
            string    NOBatches = "";
            string    s         = "";

            if (drbatch.Length != 0)
            {
                foreach (DataRow r in drbatch)
                {
                    NOBatches = NOBatches + s + r["BatchNo"].ToString() + "'";
                    s         = ",'";
                }
                NOBatches = "('" + NOBatches + ")";
            }
            NOBatchesARP = NOBatches;
            drbatch      = dbAccountingProjectDS.Batch.Select("BatchSRC = 'AR' AND BatchStat = 'P'");
            NOBatches    = "";
            s            = "";
            if (drbatch.Length != 0)
            {
                foreach (DataRow r in drbatch)
                {
                    NOBatches = NOBatches + s + r["BatchNo"].ToString() + "'";
                    s         = ",'";
                }
                NOBatches = "('" + NOBatches + ")";
            }
            NOBatchesAR = NOBatches;
            drbatch     = dbAccountingProjectDS.Batch.Select("BatchSRC = 'AR' AND BatchStat = 'P'");
            NOBatches   = "";
            s           = "";
            if (drbatch.Length != 0)
            {
                foreach (DataRow r in drbatch)
                {
                    NOBatches = NOBatches + s + r["BatchNo"].ToString() + "'";
                    s         = ",'";
                }
                NOBatches = "('" + NOBatches + ")";
            }
            DataRow[] drtrancr;
            if (NOBatches == "")
            {
                drtrancr = dbAccountingProjectDS.ARtrans.Select("Paid = 'N' AND BatchNo IN (0) AND AmountLC < 0 ");
            }
            else
            {
                drtrancr = dbAccountingProjectDS.ARtrans.Select("Paid = 'N' AND BatchNo IN " + NOBatches + " AND AmountLC < 0 ");
            }
            NOBatches = "";
            s         = "";
            if (drtrancr.Length != 0)
            {
                foreach (DataRow r in drtrancr)
                {
                    NOBatches = NOBatches + s + r["TransNO"].ToString() + "'";
                    s         = ",'";
                }
                NOBatches = "('" + NOBatches + ")";
            }
            NOTranARCredit = NOBatches;
            dtCredits      = new DataTable();
            dtCredits.Columns.Add("InvoiceID", System.Type.GetType("System.Int32"));
            dtCredits.Columns.Add("BatchNo", System.Type.GetType("System.Int32"));
            dtCredits.Columns.Add("AccountCode", System.Type.GetType("System.String"));
            dtCredits.Columns.Add("AccountName", System.Type.GetType("System.String"));
            dtCredits.Columns.Add("InvoiceDate", System.Type.GetType("System.DateTime"));
            dtCredits.Columns.Add("Reference", System.Type.GetType("System.String"));
            dtCredits.Columns.Add("Amount", System.Type.GetType("System.Double"));
            dtCredits.Columns.Add("AmountPaid", System.Type.GetType("System.Double"));
            dtCredits.Columns.Add("Balance_To_Apply", System.Type.GetType("System.Double"));
            dtCredits.Columns.Add("Curr.", System.Type.GetType("System.String"));
            dgv_CreditTransaction.DataSource = dtCredits;
            dgv_CreditTransaction.Refresh();
            dgv_CreditTransaction.Columns["InvoiceID"].Visible         = false;
            dgv_CreditTransaction.Columns["BatchNo"].ReadOnly          = true;
            dgv_CreditTransaction.Columns["AccountCode"].ReadOnly      = true;
            dgv_CreditTransaction.Columns["AccountName"].ReadOnly      = true;
            dgv_CreditTransaction.Columns["InvoiceDate"].ReadOnly      = true;
            dgv_CreditTransaction.Columns["Reference"].ReadOnly        = true;
            dgv_CreditTransaction.Columns["Amount"].ReadOnly           = true;
            dgv_CreditTransaction.Columns["AmountPaid"].ReadOnly       = true;
            dgv_CreditTransaction.Columns["Balance_To_Apply"].ReadOnly = true;
            dgv_CreditTransaction.Columns["Curr."].ReadOnly            = true;

            dtInvoice = new DataTable();
            dtInvoice.Columns.Add("InvoiceID", System.Type.GetType("System.Int32"));
            dtInvoice.Columns.Add("Select", System.Type.GetType("System.Boolean"));
            dtInvoice.Columns.Add("AccountCode", System.Type.GetType("System.String"));
            dtInvoice.Columns.Add("InvoiceDate", System.Type.GetType("System.DateTime"));
            dtInvoice.Columns.Add("Reference", System.Type.GetType("System.String"));
            dtInvoice.Columns.Add("InvoiceAmount", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AmountPaid", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("Balance", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AmtApplied", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AppliedBalance", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("Curr.", System.Type.GetType("System.String"));
            dgv_AccountCharges.DataSource = dtInvoice;
            dgv_AccountCharges.Refresh();
            dgv_AccountCharges.Columns["InvoiceID"].Visible       = false;
            dgv_AccountCharges.Columns["AccountCode"].ReadOnly    = true;
            dgv_AccountCharges.Columns["InvoiceDate"].ReadOnly    = true;
            dgv_AccountCharges.Columns["Reference"].ReadOnly      = true;
            dgv_AccountCharges.Columns["InvoiceAmount"].ReadOnly  = true;
            dgv_AccountCharges.Columns["AmountPaid"].ReadOnly     = true;
            dgv_AccountCharges.Columns["Balance"].ReadOnly        = true;
            dgv_AccountCharges.Columns["AppliedBalance"].ReadOnly = true;
            dgv_AccountCharges.Columns["Curr."].ReadOnly          = true;
            dgv_AccountCharges.Columns["AmtApplied"].DefaultCellStyle.BackColor = Color.LightGray;

            LoadTransactions();
            label_Mode.Text    = "Account Code";
            rd_Credits.Checked = true;

            cb_Currency = GeneralFunctions.FillComboBox(dbAccountingProjectDS.GLCurrency, cb_Currency, "CurrencyCode", "CurrencyNumber");
            if (GeneralFunctions.Ckecktag("15") != "M")
            {
                cb_Currency.Items.Remove("<new>");
            }
            cb_Currency = GeneralFunctions.RemoveBaseCurrency(cb_Currency);
        }
Пример #11
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "Allocation Run", "", "Open");

            if (msg != "")
            {
                MessageBox.Show("Allocation Run Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "APTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("APTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "ARTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("ARTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "ARPaymentsTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("ARPaymentsTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "JVTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("JVTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "JVEndYearAdjustments", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("JVEndYearAdjustments Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("GLTotals", "", "", "Edit");
            if (msg != "")
            {
                MessageBox.Show("GLTotals Used By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            GeneralFunctions.LockTables("GLFiscalPeriodSetup", "ENDYear", "", "Edit");
            if (DialogResult.No == MessageBox.Show("Do you want to continue Ending Year " + int.Parse(cbFiscalYear.Text) + " ? ", "Ending Year", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                return;
            }

            SqlConnection sqlDOEndMonthConnection;
            SqlCommand    sqlDoEndMonthCommand;
            int           x;
            /*******************************/
            SqlConnection sqlcheckAllPeriodsConnection = new SqlConnection(GeneralFunctions.ConnectionString);

            sqlcheckAllPeriodsConnection.Open();
            SqlCommand sqlCountPeriods = new SqlCommand("Select MAX(PeriodNumber) From GLFiscalPeriod Where YEAR(PeriodStartDate)=" + Convert.ToInt32(cbFiscalYear.Text) + "", sqlcheckAllPeriodsConnection);
            int        count           = 0;

            count = Convert.ToInt32(sqlCountPeriods.ExecuteScalar());
            int           countPeriods   = 0;
            string        PeriodsNumbers = "";
            SqlCommand    sqlcheckAllPeriodsCommand;
            SqlDataReader sqlREAD;

            for (int i = 1; i <= count; i++)
            {
                sqlcheckAllPeriodsCommand = new SqlCommand("Select PeriodDescription From GLFiscalPeriod WHere YEAR(PeriodStartDate)=" + Convert.ToInt32(cbFiscalYear.Text) + " AND PeriodDescription='Period " + i + "' AND Status='OPEN'", sqlcheckAllPeriodsConnection);
                ///countPeriods = sqlcheckAllPeriodsCommand.ExecuteNonQuery();
                sqlREAD = sqlcheckAllPeriodsCommand.ExecuteReader();
                if (sqlREAD.HasRows)
                {
                    while (sqlREAD.Read())
                    {
                        if (countPeriods == 0)
                        {
                            PeriodsNumbers = sqlREAD.GetString(0);
                        }
                        else
                        {
                            PeriodsNumbers = PeriodsNumbers + " , " + sqlREAD.GetString(0);
                        }
                        ++countPeriods;
                    }
                }
                sqlREAD.Close();
            }
            if (PeriodsNumbers != "")
            {
                MessageBox.Show("There was periods opened " + PeriodsNumbers + " you must closed them first");
                return;
            }
            else
            {
                SpecificYear = Convert.ToInt32(cbFiscalYear.Text);
                SqlConnection sqlCheckFiscalConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                SqlCommand    sqlCheckFiscalCommand;
                sqlCheckFiscalCommand = new SqlCommand("Select FiscalYear From GLFiscalPeriodSetup WHERE FiscalYear=" + Convert.ToInt32(cbFiscalYear.Text) + " + 1", sqlCheckFiscalConnection);
                sqlCheckFiscalConnection.Open();
                SqlDataReader sqlRead2;
                sqlRead2 = sqlCheckFiscalCommand.ExecuteReader();
                if (sqlRead2.HasRows)
                {
                    while (sqlRead2.Read())
                    {
                        SqlConnection sqlConnectToGLTotals = new SqlConnection(GeneralFunctions.ConnectionString);
                        sqlConnectToGLTotals.Open();
                        SqlCommand    sqlCommandOfGlTotals;
                        SqlDataReader sqlReadFromGLTotals;
                        SqlCommand    sqlCommandOfGLAccount;
                        SqlDataReader sqlReadFromGLAccounts;
                        SqlCommand    sqlUpdateData;
                        SqlConnection sqlNewConnection;
                        SqlConnection sqlnewConnection2;
                        int           countUpdatedData = 0;
                        sqlNewConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                        sqlNewConnection.Open();
                        sqlnewConnection2 = new SqlConnection(GeneralFunctions.ConnectionString);
                        sqlnewConnection2.Open();

                        if (count == 12)
                        {
                            sqlCommandOfGlTotals = new SqlCommand("Select * From GLTotals Where FiscalYear=" + Convert.ToInt32(cbFiscalYear.Text) + "", sqlConnectToGLTotals);
                            sqlReadFromGLTotals  = sqlCommandOfGlTotals.ExecuteReader();
                            if (sqlReadFromGLTotals.HasRows)
                            {
                                while (sqlReadFromGLTotals.Read())
                                {
                                    sqlCommandOfGLAccount = new SqlCommand("Select AccountTypeName From GLAccounts WHERE AccountNumber='" + sqlReadFromGLTotals.GetString(1) + "'", sqlNewConnection);
                                    sqlReadFromGLAccounts = sqlCommandOfGLAccount.ExecuteReader();
                                    if (sqlReadFromGLAccounts.HasRows)
                                    {
                                        while (sqlReadFromGLAccounts.Read())
                                        {
                                            if (sqlReadFromGLAccounts.GetString(0) == "Assets" || sqlReadFromGLAccounts.GetString(0) == "Liability" || sqlReadFromGLAccounts.GetString(0) == "Equity")
                                            {
                                                sqlUpdateData    = new SqlCommand("Update GLTotals SET BeginningBalance=" + (sqlReadFromGLTotals.GetSqlDouble(15) + sqlReadFromGLTotals.GetSqlDouble(17)) + " , PeriodBalance1=" + (sqlReadFromGLTotals.GetSqlDouble(15) + sqlReadFromGLTotals.GetSqlDouble(17)) + " WHERE AccountNumber='" + sqlReadFromGLTotals.GetString(1) + "' AND FiscalYear=" + (Convert.ToInt32(cbFiscalYear.Text) + 1) + "", sqlnewConnection2);
                                                countUpdatedData = sqlUpdateData.ExecuteNonQuery();
                                            }
                                        }
                                    }
                                    sqlReadFromGLAccounts.Close();
                                }
                            }
                        }
                        else if (count == 13)
                        {
                            sqlCommandOfGlTotals = new SqlCommand("Select * From GLTotals Where FiscalYear=" + Convert.ToInt32(cbFiscalYear.Text) + "", sqlConnectToGLTotals);
                            sqlReadFromGLTotals  = sqlCommandOfGlTotals.ExecuteReader();
                            if (sqlReadFromGLTotals.HasRows)
                            {
                                while (sqlReadFromGLTotals.Read())
                                {
                                    sqlCommandOfGLAccount = new SqlCommand("Select AccountTypeName From GLAccounts WHERE AccountNumber='" + sqlReadFromGLTotals.GetString(1) + "'", sqlNewConnection);
                                    sqlReadFromGLAccounts = sqlCommandOfGLAccount.ExecuteReader();
                                    if (sqlReadFromGLAccounts.HasRows)
                                    {
                                        while (sqlReadFromGLAccounts.Read())
                                        {
                                            if (sqlReadFromGLAccounts.GetString(0) == "Assets" || sqlReadFromGLAccounts.GetString(0) == "Liability" || sqlReadFromGLAccounts.GetString(0) == "Equity")
                                            {
                                                sqlUpdateData    = new SqlCommand("Update GLTotals SET BeginningBalance=" + (sqlReadFromGLTotals.GetSqlDouble(16) + sqlReadFromGLTotals.GetSqlDouble(17)) + " , PeriodBalance1=" + (sqlReadFromGLTotals.GetSqlDouble(16) + sqlReadFromGLTotals.GetSqlDouble(17)) + " WHERE AccountNumber='" + sqlReadFromGLTotals.GetString(1) + "' AND FiscalYear=" + (Convert.ToInt32(cbFiscalYear.Text) + 1) + "", sqlnewConnection2);
                                                countUpdatedData = sqlUpdateData.ExecuteNonQuery();
                                            }
                                        }
                                    }
                                    sqlReadFromGLAccounts.Close();
                                }
                            }


                            sqlnewConnection2.Close();
                            sqlNewConnection.Close();
                        }
                    }

                    sqlDOEndMonthConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                    sqlDoEndMonthCommand    = new SqlCommand("Update GLFiscalPeriodSetup SET Status='CLOSED' WHERE FiscalYear=" + Convert.ToInt32(cbFiscalYear.Text) + "", sqlDOEndMonthConnection);
                    sqlDOEndMonthConnection.Open();
                    x = sqlDoEndMonthCommand.ExecuteNonQuery();
                    sqlDOEndMonthConnection.Close();
                    MessageBox.Show("End Year Successfully", "Valid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    refill();
                    refillyear();
                }
                else
                {
                    MessageBox.Show("Please Make fiscal year for the next year first", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
            }
            GeneralFunctions.UnLockTable("", "ENDYear", "", "Edit");
        }
Пример #12
0
        private void ApplyCreditsScreen_Load(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "ApplyCreditsScreen", "", "Open");

            if (msg != "")
            {
                MessageBox.Show("ApplyCreditsScreen Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                btn_Save.Visible = false;
            }
            GeneralFunctions.LockTables("", "ApplyCreditsScreen", "", "Open");
            sqlcon                   = new SqlConnection(GeneralFunctions.ConnectionString);
            adaptertbAPCredits       = new SqlDataAdapter("Select * from APCredits", sqlcon);
            adaptertbBatch           = new SqlDataAdapter("Select * from Batch", sqlcon);
            adaptertbBatchInvoices   = new SqlDataAdapter("Select * from APTrans", sqlcon);
            adaptertbInvoiceAccounts = new SqlDataAdapter("Select * from APExpense", sqlcon);
            adaptertbCurrency        = new SqlDataAdapter("Select * from GLCurrency", sqlcon);

            cmdBuilder          = new SqlCommandBuilder(adaptertbBatchInvoices);
            cmdBuilderAPCredits = new SqlCommandBuilder(adaptertbAPCredits);

            adaptertbBatch.Fill(dbAccountingProjectDS.Batch);
            adaptertbAPCredits.Fill(dbAccountingProjectDS.APCredits);
            adaptertbBatchInvoices.Fill(dbAccountingProjectDS.APTrans);
            adaptertbInvoiceAccounts.Fill(dbAccountingProjectDS.APExpense);
            adaptertbCurrency.Fill(dbAccountingProjectDS.GLCurrency);
            adaptertbGeneralSetup = new SqlDataAdapter("Select * from GeneralSetup", sqlcon);
            adaptertbGeneralSetup.Fill(dbAccountingProjectDS.GeneralSetup);
            foreach (DataRow dr in dbAccountingProjectDS.GeneralSetup.Rows)
            {
                decmal = int.Parse(dr["DecimalPointsNumber"].ToString());
            }
            dtCredits = new DataTable();
            dtCredits.Columns.Add("InvoiceID", System.Type.GetType("System.Int32"));
            dtCredits.Columns.Add("BatchNo", System.Type.GetType("System.Int32"));
            dtCredits.Columns.Add("VendorCode", System.Type.GetType("System.String"));
            dtCredits.Columns.Add("VendorName", System.Type.GetType("System.String"));
            dtCredits.Columns.Add("InvoiceDate", System.Type.GetType("System.DateTime"));
            dtCredits.Columns.Add("Reference", System.Type.GetType("System.String"));
            dtCredits.Columns.Add("Amount", System.Type.GetType("System.Double"));
            dtCredits.Columns.Add("AmountPaid", System.Type.GetType("System.Double"));
            dtCredits.Columns.Add("Balance_To_Apply", System.Type.GetType("System.Double"));
            dtCredits.Columns.Add("Curr.", System.Type.GetType("System.String"));
            dgv_CreditTransaction.DataSource = dtCredits;
            dgv_CreditTransaction.Refresh();
            dgv_CreditTransaction.Columns["InvoiceID"].Visible         = false;
            dgv_CreditTransaction.Columns["BatchNo"].ReadOnly          = true;
            dgv_CreditTransaction.Columns["VendorCode"].ReadOnly       = true;
            dgv_CreditTransaction.Columns["VendorName"].ReadOnly       = true;
            dgv_CreditTransaction.Columns["InvoiceDate"].ReadOnly      = true;
            dgv_CreditTransaction.Columns["Reference"].ReadOnly        = true;
            dgv_CreditTransaction.Columns["Amount"].ReadOnly           = true;
            dgv_CreditTransaction.Columns["AmountPaid"].ReadOnly       = true;
            dgv_CreditTransaction.Columns["Balance_To_Apply"].ReadOnly = true;
            dgv_CreditTransaction.Columns["Curr."].ReadOnly            = true;
            dtInvoice = new DataTable();
            dtInvoice.Columns.Add("InvoiceID", System.Type.GetType("System.Int32"));
            dtInvoice.Columns.Add("Select", System.Type.GetType("System.Boolean"));
            dtInvoice.Columns.Add("VendorCode", System.Type.GetType("System.String"));
            dtInvoice.Columns.Add("InvoiceDate", System.Type.GetType("System.DateTime"));
            dtInvoice.Columns.Add("Reference", System.Type.GetType("System.String"));
            dtInvoice.Columns.Add("InvoiceAmount", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("TaxValue", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AmountPaid", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("Balance", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AmtApplied", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AppliedBalance", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("Curr.", System.Type.GetType("System.String"));
            dgv_AccountCharges.DataSource = dtInvoice;
            dgv_AccountCharges.Refresh();
            dgv_AccountCharges.Columns["InvoiceID"].Visible       = false;
            dgv_AccountCharges.Columns["VendorCode"].ReadOnly     = true;
            dgv_AccountCharges.Columns["InvoiceDate"].ReadOnly    = true;
            dgv_AccountCharges.Columns["Reference"].ReadOnly      = true;
            dgv_AccountCharges.Columns["InvoiceAmount"].ReadOnly  = true;
            dgv_AccountCharges.Columns["TaxValue"].ReadOnly       = true;
            dgv_AccountCharges.Columns["AmountPaid"].ReadOnly     = true;
            dgv_AccountCharges.Columns["Balance"].ReadOnly        = true;
            dgv_AccountCharges.Columns["AppliedBalance"].ReadOnly = true;
            dgv_AccountCharges.Columns["Curr."].ReadOnly          = true;
            dgv_AccountCharges.Columns["AmtApplied"].DefaultCellStyle.BackColor = Color.LightGray;

            LoadTransactions();
            label_Mode.Text    = "Vendor Code";
            rd_Credits.Checked = true;

            cb_Currency = GeneralFunctions.FillComboBox(dbAccountingProjectDS.GLCurrency, cb_Currency, "CurrencyCode", "CurrencyNumber");
            if (GeneralFunctions.Ckecktag("15") != "M")
            {
                cb_Currency.Items.Remove("<new>");
            }
            cb_Currency = GeneralFunctions.RemoveBaseCurrency(cb_Currency);
        }
Пример #13
0
        private void GeneralSetup_Load(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "", "", "");

            if (msg != "")
            {
                MessageBox.Show("Can't Open Because Other Form Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.Close();
                return;
            }
            GeneralFunctions.LockTables("All", "GeneralSetup", "", "");

            string BS = "";

            EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);

            dbAccountingProjectDS = new dbAccountingProjectDS();
            sqlcon = new SqlConnection(GeneralFunctions.ConnectionString);
            FillNumberFormat(cb_APNumberFormat);
            FillNumberFormat(cb_ARNumberFormat);
            FillNumberFormat(cb_JVNumberFormat);
            FillNumberFormat(cb_BankNumberFormat);
            adaptertbGeneralSetup  = new SqlDataAdapter("Select * From GeneralSetup", sqlcon);
            cmdBuilderGeneralSetup = new SqlCommandBuilder(adaptertbGeneralSetup);
            adaptertbGeneralSetup.Fill(dbAccountingProjectDS.GeneralSetup);
            foreach (DataRow dr in dbAccountingProjectDS.GeneralSetup.Rows)
            {
                txtMaxAccountNo.Text     = dr["AccountNumberFormat"].ToString();
                txtDecimalPoint.Text     = dr["DecimalPointFormat"].ToString();
                cb_JVNumberFormat.Text   = dr["JVNumberFormat"].ToString();
                cb_APNumberFormat.Text   = dr["APNumberFormat"].ToString();
                cb_ARNumberFormat.Text   = dr["ARNumberFormat"].ToString();
                cb_BankNumberFormat.Text = dr["BankNumberFormat"].ToString();
                lblAP.Text   = dr["lblAP"].ToString();
                lblAR.Text   = dr["lblAR"].ToString();
                lblJV.Text   = dr["lblJV"].ToString();
                lblBank.Text = dr["lblBank"].ToString();
                //txt_SublevelNumber.Text = dr["AccountsChartSubLevels"].ToString();
                tempAccountNumber       = dr["AccountNumberFormat"].ToString();
                cbMultiCurrency.Checked = Convert.ToBoolean(dr["MultiCurrency"].ToString());
                comboBox_language.Text  = dr["SelectedLanguage"].ToString();
                BS = dr["BalanceSheet"].ToString();
                if (BS.Trim() == "")
                {
                    cmbBS.SelectedIndex = -1;
                }
                else
                {
                    cmbBS.Text = GeneralFunctions.Decrypt(BS);
                }
            }

            if (GeneralFunctions.languagechioce != "")
            {
                this.obj_options = new ClassOptions();
                this.obj_options.report_language = GeneralFunctions.languagechioce;
                this.update_language_interface();
            }
            //GLInterface gl=new GLInterface();
            comboBox_language.Items.AddRange(GLInterface.report_language_available);
        }
Пример #14
0
        private void ARSystemControl_Load(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "", "", "");

            if (msg != "")
            {
                MessageBox.Show("Can't Open Because Other Form Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.Close();
                return;
            }
            GeneralFunctions.LockTables("All", "ARSystemControl", "", "");

            this.ARSystemSetupTableAdapter = new Accounting_GeneralLedger.dbAccountingProjectDSTableAdapters.ARSystemSetupTableAdapter();
            // TODO: This line of code loads data into the 'dbAccountingProjectDS.GLAccounts' table. You can move, or remove it, as needed.

            this.ARSystemSetupTableAdapter.Fill(this.dbAccountingProjectDS.ARSystemSetup);
            this.gLAccountsTableAdapter.Fill(this.dbAccountingProjectDS.GLAccounts);
            // TODO: This line of code loads data into the 'dbAccountingProjectDS.ARTransactionCodes' table. You can move, or remove it, as needed.
            this.aRTransactionCodesTableAdapter.Fill(this.dbAccountingProjectDS.ARTransactionCodes);
            // TODO: This line of code loads data into the 'dbAccountingProjectDS.APTrans' table. You can move, or remove it, as needed.
            this.aPTransTableAdapter.Fill(this.dbAccountingProjectDS.APTrans);

            //GeneralFunctions.priviledgeGroupBox(ARGroup);
            SqlConnection sqlcon = new SqlConnection(GeneralFunctions.ConnectionString);

            sqlcon.Open();
            SqlCommand    sqlcomm = new SqlCommand("Select * From ARSystemSetup", sqlcon);
            SqlDataReader sqlread = sqlcomm.ExecuteReader();

            if (sqlread.HasRows)
            {
                while (sqlread.Read())
                {
                    #region TabOneControls
                    txtID.Text                = sqlread["ARSetupID"].ToString();
                    txt_GLAccount.Text        = sqlread["ARAccountNum"].ToString();
                    YearsToRetain.Value       = decimal.Parse(sqlread["YearsToRetain"].ToString());
                    MonthForArchieve.Value    = decimal.Parse(sqlread["MonthAllowed"].ToString());
                    chxOverCredit.Checked     = bool.Parse(sqlread["DisplayOverCredit"].ToString());
                    chxConfirmation.Checked   = bool.Parse(sqlread["DisplayConfirmation"].ToString());
                    chxRequire.Checked        = bool.Parse(sqlread["RequireFirst"].ToString());
                    ComboStatus.SelectedValue = (object)(sqlread["AccStatus"].ToString());


                    txt_CreditLimit.Text            = sqlread["AccCredit"].ToString();
                    txt_Annual.Text                 = sqlread["AnnualFinance"].ToString();
                    txt_MinmumFinance.Text          = sqlread["MinmumFinance"].ToString();
                    txt_FinanceCharge.Text          = sqlread["FinanceChargeDay"].ToString();
                    txt_nightAudit.Text             = sqlread["NightAuditCode"].ToString();
                    txt_DefaultDirectory.Text       = sqlread["DefaultDocument"].ToString();
                    Combo_Transaction.SelectedValue = (object)(sqlread["FinanceTransCode"].ToString());
                    chxCompound.Checked             = bool.Parse(sqlread["CompoundFinance"].ToString());

                    #endregion

                    #region Tab2Controls



                    chxPrintTax.Checked          = bool.Parse(sqlread["PrintTax"].ToString());
                    chxPrintInformation.Checked  = bool.Parse(sqlread["PrintInfo"].ToString());
                    chxAutomaticInvoices.Checked = bool.Parse(sqlread["AutoInvoices"].ToString());
                    chxEmailInvoices.Checked     = bool.Parse(sqlread["EmailInvoices"].ToString());
                    chxPrintStat.Checked         = bool.Parse(sqlread["PrintStatement"].ToString());
                    chxShowAllTrans.Checked      = bool.Parse(sqlread["ShowTransBill"].ToString());
                    chxDisplayOriginal.Checked   = bool.Parse(sqlread["DisplayOriginalCharge"].ToString());
                    chxImportCard.Checked        = bool.Parse(sqlread["ImportCreditCard"].ToString());
                    chxUseAR.Checked             = bool.Parse(sqlread["UseARTax"].ToString());
                    chxUseInvoicesDate.Checked   = bool.Parse(sqlread["UseInvoiceDate"].ToString());
                    chx_AgeCredits.Checked       = bool.Parse(sqlread["AgeCredits"].ToString());

                    txt_AgingPeriodFifth.Text = sqlread["DAgingFive"].ToString();
                    txt_AgingPeriodForth.Text = sqlread["DAgingFour"].ToString();
                    txt_AgingPeriodThree.Text = sqlread["DAgingThree"].ToString();
                    txt_AgingPeriodTow.Text   = sqlread["DAgingTOW"].ToString();
                    txt_AgingPeriodOne.Text   = sqlread["DAgingONE"].ToString();
                    txt_DaysPeriodFifth.Text  = sqlread["DPeriodFive"].ToString();
                    txt_DaysPeriodforth.Text  = sqlread["DPeriodFour"].ToString();
                    txt_DaysPeriodThree.Text  = sqlread["DPeriodThree"].ToString();
                    txt_DaysPeriodTow.Text    = sqlread["DPeriodTow"].ToString();
                    txt_DaysPeriodOne.Text    = sqlread["DPeriodONE"].ToString();
                    txt_FinanceDesc.Text      = sqlread["FinanceDesc"].ToString();
                    txt_BalanceDesc.Text      = sqlread["BalanceDesc"].ToString();

                    ComboStatement.SelectedValue = sqlread["StatementAccount"];
                    radio_BalanceForword.Checked = bool.Parse(sqlread["BalanceForword"].ToString());
                    radio_OpenItem.Checked       = bool.Parse(sqlread["OpenItem"].ToString());
                    #endregion

                    #region Tab3Controls


                    txt_SMTP.Text                   = sqlread["ServerStp"].ToString();
                    txt_EmailAdd.Text               = sqlread["EmailAdd"].ToString();
                    txt_AuthLogin.Text              = sqlread["AuthentLog"].ToString();
                    txt_Password.Text               = sqlread["AuthentPass"].ToString();
                    txt_ARCode.Text                 = sqlread["ARCodeForInvalid"].ToString();
                    txtTerminalID.Text              = sqlread["TerminalID"].ToString();
                    chxAuthentication.Checked       = bool.Parse(sqlread["UseAuthent"].ToString());
                    chxAutoPost.Checked             = bool.Parse(sqlread["AutoPost"].ToString());
                    chxCreditProcessing.Checked     = bool.Parse(sqlread["CreditProcessing"].ToString());
                    chxCreditTracking.Checked       = bool.Parse(sqlread["CreditTracking"].ToString());
                    chxUseCreditPrinting.Checked    = bool.Parse(sqlread["CreditPrinting"].ToString());
                    chxDontStore.Checked            = bool.Parse(sqlread["DontStore"].ToString());
                    chxTimeShare.Checked            = bool.Parse(sqlread["TimeShare"].ToString());
                    radioHotel.Checked              = bool.Parse(sqlread["HotelIndust"].ToString());
                    radioMarketing.Checked          = bool.Parse(sqlread["DirectMarket"].ToString());
                    comboPrinterType.SelectedItem   = sqlread["PrinterType"];
                    comboProcessorType.SelectedItem = sqlread["ProcessType"];
                    #endregion
                }
                sqlread.Close();
            }
            else
            {
                ClearControls();

                txtID.Text = "1";


                SaveNewBtn.Visible   = true;
                btnedit.Visible      = false;
                Btnsaveedit.Visible  = false;
                tab1groupBox.Enabled = true;
                Tab2groupBox.Enabled = true;
                tab3groupBox.Enabled = true;
            }
        }
Пример #15
0
        private void AP_Manual_Check_Load(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "AP_Manual_Check", "", "Open");

            if (msg != "")
            {
                MessageBox.Show("AP_Manual_Check Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                btn_Save.Visible = false;
            }
            GeneralFunctions.LockTables("", "AP_Manual_Check", "", "Open");
            sqlcon = new SqlConnection(GeneralFunctions.ConnectionString);
            adaptertbChecks_Serial     = new SqlDataAdapter("Select * from Checks_Serial", sqlcon);
            adaptertbCheck_Pay_Invoice = new SqlDataAdapter("Select * from Check_Pay_Invoice", sqlcon);
            adaptertbBatch             = new SqlDataAdapter("Select * from Batch", sqlcon);
            adaptertbBatchInvoices     = new SqlDataAdapter("Select * from APTrans", sqlcon);

            cmdBuilderBatchInvoices     = new SqlCommandBuilder(adaptertbBatchInvoices);
            cmdBuilderBatch             = new SqlCommandBuilder(adaptertbBatch);
            cmdBuilderChecks_Serial     = new SqlCommandBuilder(adaptertbChecks_Serial);
            cmdBuilderCheck_Pay_Invoice = new SqlCommandBuilder(adaptertbCheck_Pay_Invoice);
            adaptertbBatchInvoices.Fill(dbAccountingProjectDS.APTrans);
            adaptertbBatch.Fill(dbAccountingProjectDS.Batch);
            adaptertbChecks_Serial.Fill(dbAccountingProjectDS.Checks_Serial);
            adaptertbCheck_Pay_Invoice.Fill(dbAccountingProjectDS.Check_Pay_Invoice);

            adaptertbAccounts         = new SqlDataAdapter("Select * from GLAccounts", sqlcon);
            adaptertbFiscalPeriod     = new SqlDataAdapter("Select * from GLFiscalPeriod", sqlcon);
            adaptertbGLTotals         = new SqlDataAdapter("Select * from GLTotals", sqlcon);
            adaptertbGLTransactions   = new SqlDataAdapter("Select * From GLTransactions", sqlcon);
            adaptertbGeneralSetup     = new SqlDataAdapter("Select * from GeneralSetup", sqlcon);
            adaptertbG_L_GeneralSetup = new SqlDataAdapter("Select * from G_L_GeneralSetup", sqlcon);
            cmdBuilderGLTotals        = new SqlCommandBuilder(adaptertbGLTotals);
            cmdGLTransactions         = new SqlCommandBuilder(adaptertbGLTransactions);
            adaptertbFiscalPeriod.Fill(dbAccountingProjectDS.GLFiscalPeriod);
            adaptertbAccounts.Fill(dbAccountingProjectDS.GLAccounts);
            adaptertbGLTotals.Fill(dbAccountingProjectDS.GLTotals);
            adaptertbGLTransactions.Fill(dbAccountingProjectDS.GLTransactions);
            adaptertbGeneralSetup.Fill(dbAccountingProjectDS.GeneralSetup);
            adaptertbG_L_GeneralSetup.Fill(dbAccountingProjectDS.G_L_GeneralSetup);
            foreach (DataRow dr in dbAccountingProjectDS.GeneralSetup.Rows)
            {
                GeneralFunctions.BankNumberFormat    = dr["BankNumberFormat"].ToString();
                GeneralFunctions.DecimalPointsNumber = int.Parse(dr["DecimalPointsNumber"].ToString());
                AccountNumberFormat = dr["AccountNumberFormat"].ToString();
                decmal = int.Parse(dr["DecimalPointsNumber"].ToString());
                GeneralFunctions.lblBank = dr["lblBank"].ToString();
            }

            DataRow[] drs = dbAccountingProjectDS.G_L_GeneralSetup.Select();
            if (drs.Length != 0)
            {
                DefaultACCBalanceSheet   = drs[0]["BalanceSheet"].ToString();
                DefaultACCIncomeStatment = drs[0]["IncomeStatment"].ToString();
                JNL_BankDeposit          = drs[0]["BankDepost"].ToString();
                if (DefaultACCBalanceSheet == "" || DefaultACCIncomeStatment == "")
                {
                    MessageBox.Show("Please Check AccountBalanceSheet And AccountIncomeStatment In G/L GeneralSetup ", "Error");
                    this.Close();
                }
            }
            dtInvoice = new DataTable();
            dtInvoice.Columns.Add("InvoiceID", System.Type.GetType("System.Int32"));
            dtInvoice.Columns.Add("Select", System.Type.GetType("System.Boolean"));
            dtInvoice.Columns.Add("VendorCode", System.Type.GetType("System.String"));
            dtInvoice.Columns.Add("InvoiceDate", System.Type.GetType("System.DateTime"));
            dtInvoice.Columns.Add("Reference", System.Type.GetType("System.String"));
            dtInvoice.Columns.Add("InvoiceAmount", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("TaxValue", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AmountPaid", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("Balance", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AmtApplied", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("AppliedBalance", System.Type.GetType("System.Double"));
            dtInvoice.Columns.Add("Curr.", System.Type.GetType("System.String"));
            dgv_AccountCharges.DataSource = dtInvoice;
            dgv_AccountCharges.Refresh();
            dgv_AccountCharges.Columns["InvoiceID"].Visible       = false;
            dgv_AccountCharges.Columns["Select"].ReadOnly         = true;
            dgv_AccountCharges.Columns["VendorCode"].ReadOnly     = true;
            dgv_AccountCharges.Columns["InvoiceDate"].ReadOnly    = true;
            dgv_AccountCharges.Columns["Reference"].ReadOnly      = true;
            dgv_AccountCharges.Columns["InvoiceAmount"].ReadOnly  = true;
            dgv_AccountCharges.Columns["TaxValue"].ReadOnly       = true;
            dgv_AccountCharges.Columns["AmountPaid"].ReadOnly     = true;
            dgv_AccountCharges.Columns["Balance"].ReadOnly        = true;
            dgv_AccountCharges.Columns["AppliedBalance"].ReadOnly = true;
            dgv_AccountCharges.Columns["Curr."].ReadOnly          = true;
            dgv_AccountCharges.Columns["Curr."].Visible           = false;
            dgv_AccountCharges.Columns["AmtApplied"].DefaultCellStyle.BackColor = Color.LightGray;
            string periodName;

            if (GeneralFunctions.RetrievePeriod(string.Format(GeneralFunctions.Format_Date, DTP_JVDate.Value.Date), out currentPeriodID, out periodName, out currentEndDate))
            {
                txt_Period.Text = periodName;
            }
            else
            {
                MessageBox.Show("The period has been defined", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DataTable DtCat = DataClass.RetrieveData("Select Bank_Deposit_Type_ID,Bank_Deposit_Type_Name From Bank_Deposit_Type ");

            cb_Bank_Account_ID.DataSource    = DtCat;
            cb_Bank_Account_ID.DisplayMember = "Bank_Deposit_Type_Name";
            cb_Bank_Account_ID.ValueMember   = "Bank_Deposit_Type_ID";
            cb_Bank_Account_ID.SelectedIndex = -1;
        }
Пример #16
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            string msg = GeneralFunctions.CheckLockTables("", "Allocation Run", "", "Open");

            if (msg != "")
            {
                MessageBox.Show("Allocation Run Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "APTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("APTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("GLTotals", "", "", "Edit");
            if (msg != "")
            {
                MessageBox.Show("GLTotals Used By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "ARTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("ARTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "ARPaymentsTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("ARPaymentsTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            msg = GeneralFunctions.CheckLockTables("", "JVTransactions", "", "Open");
            if (msg != "")
            {
                MessageBox.Show("JVTransactions Open By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            GeneralFunctions.LockTables("GLFiscalPeriod", "EndMonth", "", "Edit");
            if (cbFiscalPeriod.Items.Count == 0)
            {
                return;
            }
            string prd = cbFiscalPeriod.Text.Substring(0, cbFiscalPeriod.Text.IndexOf('/'));
            int    Y   = int.Parse(cbFiscalPeriod.Text.Substring(cbFiscalPeriod.Text.IndexOf('/') + 1));

            if (DialogResult.No == MessageBox.Show("Do you want to continue End " + prd + " ? ", "Ending Period", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                return;
            }
            SqlConnection sqlcheckAllPeriodsConnection = new SqlConnection(GeneralFunctions.ConnectionString);

            sqlcheckAllPeriodsConnection.Open();
            SqlCommand sqlCountPeriods = new SqlCommand("Select MAX(PeriodNumber) From GLFiscalPeriod Where YEAR(PeriodStartDate)=" + Y + "", sqlcheckAllPeriodsConnection);
            int        count           = 0;

            count = Convert.ToInt32(sqlCountPeriods.ExecuteScalar());
            sqlcheckAllPeriodsConnection.Close();
            SqlConnection sqlDOEndMonthConnection;
            SqlCommand    sqlDoEndMonthCommand;
            SqlDataReader sqlReadPeriod;
            SqlConnection sqlInnerConnection;
            SqlCommand    sqlInnerCommand;
            int           x;
            /*******************************/
            SqlConnection sqlCheckUnpostedBatchesConnection = new SqlConnection(GeneralFunctions.ConnectionString);
            SqlCommand    sqlCheckUnpostedBatchesCommand    = new SqlCommand("Select * From Batch WHERE BatchStat Like 'U%' AND BatchPRD='" + prd + "' AND YEAR(BatchDate)=" + Y + "", sqlCheckUnpostedBatchesConnection);

            SpecificPeriod = prd;
            SpecificYear   = Y;
            //MessageBox.Show("Ending Period " + SpecificYear);
            if (sqlCheckUnpostedBatchesConnection.State == ConnectionState.Open)
            {
                sqlCheckUnpostedBatchesConnection.Close();
            }
            sqlCheckUnpostedBatchesConnection.Open();
            SqlDataReader sqlCheckUnpostedBatchesRead;

            sqlCheckUnpostedBatchesRead = sqlCheckUnpostedBatchesCommand.ExecuteReader();
            if (sqlCheckUnpostedBatchesRead.HasRows)
            {
                ShowUnpostedJV sunp = new ShowUnpostedJV();
                sunp.ShowDialog();
                MessageBox.Show("Can't End This Period Because this Period Containing Batches Un Posted", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                sqlCheckUnpostedBatchesConnection.Close();
                sqlCheckUnpostedBatchesRead.Close();
            }
            else
            {
                sqlCheckUnpostedBatchesConnection.Close();
                sqlCheckUnpostedBatchesRead.Close();
                sqlCheckUnpostedBatchesCommand = new SqlCommand("Select * From GLFiscalPeriodSetup WHERE FiscalYear = " + Convert.ToString(SpecificYear - 1) + " AND Status = 'OPEN'", sqlCheckUnpostedBatchesConnection);
                if (sqlCheckUnpostedBatchesConnection.State == ConnectionState.Open)
                {
                    sqlCheckUnpostedBatchesConnection.Close();
                }
                sqlCheckUnpostedBatchesConnection.Open();
                SqlDataReader sqlChecklastyearRead;
                sqlChecklastyearRead = sqlCheckUnpostedBatchesCommand.ExecuteReader();
                if (sqlChecklastyearRead.HasRows)
                {
                    MessageBox.Show("Can't End This Period Because Year = " + Convert.ToString(SpecificYear - 1) + " Is Open", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    sqlCheckUnpostedBatchesRead.Close();
                    sqlCheckUnpostedBatchesConnection.Close();
                    return;
                }
                sqlCheckUnpostedBatchesRead.Close();
                sqlCheckUnpostedBatchesConnection.Close();
                sqlDOEndMonthConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                sqlDoEndMonthCommand    = new SqlCommand("Select PeriodNumber From GLFiscalPeriod WHERE PeriodDescription='" + prd + "' AND YEAR(PeriodStartDate)=" + Y + "", sqlDOEndMonthConnection);
                sqlDOEndMonthConnection.Open();
                sqlReadPeriod = sqlDoEndMonthCommand.ExecuteReader();

                sqlReadPeriod.Read();
                int PeriodID = sqlReadPeriod.GetInt32(0);
                sqlReadPeriod.Close();
                sqlDOEndMonthConnection.Close();
                if (PeriodID != 13 && PeriodID != 12)
                {
                    sqlInnerConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                    sqlInnerConnection.Open();
                    sqlInnerCommand = new SqlCommand("Update GLTotals SET PeriodBalance" + Convert.ToString(PeriodID + 1) + "=PeriodBalance" + Convert.ToString(PeriodID + 1) + "+PeriodBalance" + PeriodID.ToString() + " WHERE FiscalYear=" + Y + "", sqlInnerConnection);
                    x = sqlInnerCommand.ExecuteNonQuery();
                    sqlInnerConnection.Close();
                }
                else if (PeriodID == 12 && count == 13)
                {
                    sqlInnerConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                    sqlInnerConnection.Open();
                    sqlInnerCommand = new SqlCommand("Update GLTotals SET PeriodBalance" + Convert.ToString(PeriodID + 1) + "=PeriodBalance" + Convert.ToString(PeriodID + 1) + "+PeriodBalance" + PeriodID.ToString() + " WHERE FiscalYear=" + Y + "", sqlInnerConnection);
                    x = sqlInnerCommand.ExecuteNonQuery();
                    sqlInnerConnection.Close();
                }
                sqlDOEndMonthConnection = new SqlConnection(GeneralFunctions.ConnectionString);
                sqlDoEndMonthCommand    = new SqlCommand("Update GLFiscalPeriod SET Status='CLOSED' WHERE PeriodDescription='" + prd + "' AND YEAR(PeriodStartDate)=" + Y + "", sqlDOEndMonthConnection);
                sqlDOEndMonthConnection.Open();
                x = sqlDoEndMonthCommand.ExecuteNonQuery();
                sqlDOEndMonthConnection.Close();
                MessageBox.Show("End Period Successfully", "Valid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                refill();
                refillprd();
            }
            GeneralFunctions.UnLockTable("", "EndMonth", "", "Edit");
        }
Пример #17
0
        private void Bank_Deposit_Load(object sender, EventArgs e)
        {
            try
            {
                string msg = GeneralFunctions.CheckLockTables("", "ENDYear", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("Can't Open Because ENDYear Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
                msg = GeneralFunctions.CheckLockTables("", "EndMonth", "", "Edit");
                if (msg != "")
                {
                    MessageBox.Show("Can't Open Because EndMonth Edit By " + msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
                GeneralFunctions.LockTables("", "Bank_Deposit", "", "Open");
                // TODO: This line of code loads data into the 'dbAccountingProjectDS1.BatchTemp' table. You can move, or remove it, as needed.
                dbAccountingProjectDS = new dbAccountingProjectDS();
                sqlcon                    = new SqlConnection(GeneralFunctions.ConnectionString);
                adaptertbAccounts         = new SqlDataAdapter("Select * from GLAccounts", sqlcon);
                adaptertbFiscalPeriod     = new SqlDataAdapter("Select * from GLFiscalPeriod", sqlcon);
                adaptertbGLTotals         = new SqlDataAdapter("Select * from GLTotals", sqlcon);
                adaptertbBatch            = new SqlDataAdapter("Select * From Batch", sqlcon);
                adaptertbGLTransactions   = new SqlDataAdapter("Select * From GLTransactions", sqlcon);
                adaptertbGeneralSetup     = new SqlDataAdapter("Select * from GeneralSetup", sqlcon);
                adaptertbG_L_GeneralSetup = new SqlDataAdapter("Select * from G_L_GeneralSetup", sqlcon);
                cmdBuilderGLTotals        = new SqlCommandBuilder(adaptertbGLTotals);
                cmdBuilderBatch           = new SqlCommandBuilder(adaptertbBatch);
                cmdGLTransactions         = new SqlCommandBuilder(adaptertbGLTransactions);
                adaptertbFiscalPeriod.Fill(dbAccountingProjectDS.GLFiscalPeriod);
                adaptertbAccounts.Fill(dbAccountingProjectDS.GLAccounts);
                adaptertbGLTotals.Fill(dbAccountingProjectDS.GLTotals);
                adaptertbBatch.Fill(dbAccountingProjectDS.Batch);
                adaptertbGLTransactions.Fill(dbAccountingProjectDS.GLTransactions);
                adaptertbGeneralSetup.Fill(dbAccountingProjectDS.GeneralSetup);
                adaptertbG_L_GeneralSetup.Fill(dbAccountingProjectDS.G_L_GeneralSetup);
                foreach (DataRow dr in dbAccountingProjectDS.GeneralSetup.Rows)
                {
                    GeneralFunctions.BankNumberFormat    = dr["BankNumberFormat"].ToString();
                    GeneralFunctions.DecimalPointsNumber = int.Parse(dr["DecimalPointsNumber"].ToString());
                    AccountNumberFormat = dr["AccountNumberFormat"].ToString();
                    decmal = int.Parse(dr["DecimalPointsNumber"].ToString());
                    GeneralFunctions.lblBank = dr["lblBank"].ToString();
                }

                DataRow[] drs = dbAccountingProjectDS.G_L_GeneralSetup.Select();
                if (drs.Length != 0)
                {
                    DefaultACCBalanceSheet   = drs[0]["BalanceSheet"].ToString();
                    DefaultACCIncomeStatment = drs[0]["IncomeStatment"].ToString();
                    JNL_BankDeposit          = drs[0]["BankDepost"].ToString();
                    if (DefaultACCBalanceSheet == "" || DefaultACCIncomeStatment == "")
                    {
                        MessageBox.Show("Please Check AccountBalanceSheet And AccountIncomeStatment In G/L GeneralSetup ", "Error");
                        this.Close();
                    }
                }
                string periodName;
                if (GeneralFunctions.RetrievePeriod(string.Format(GeneralFunctions.Format_Date, DTP_JVDate.Value.Date), out currentPeriodID, out periodName, out currentEndDate))
                {
                    txt_Period.Text = periodName;
                }
                else
                {
                    MessageBox.Show("The period has been defined", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


                if (GeneralFunctions.languagechioce != "")
                {
                    this.obj_options = new ClassOptions();
                    this.obj_options.report_language = GeneralFunctions.languagechioce;
                    this.update_language_interface();
                }

                DataTable DtCat = DataClass.RetrieveData("Select Bank_Deposit_Type_ID,Bank_Deposit_Type_Name From Bank_Deposit_Type ");
                cb_Bank_Deposit_Type.DataSource    = DtCat;
                cb_Bank_Deposit_Type.DisplayMember = "Bank_Deposit_Type_Name";
                cb_Bank_Deposit_Type.ValueMember   = "Bank_Deposit_Type_ID";
                cb_Bank_Deposit_Type.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }