//================================================================================================================================================//
        // LOAD HOURS OF CONTRACTOR                                                                                                                       //
        //================================================================================================================================================//
        private void LoadHours()
        {
            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter("SELECT Code, Date_Start, Date_End, Hours, Rate_Per_Hour, Total_$, Exchange_Rate, Total_R, "
                                                       + "QTech_Cut, Final_Total, Remittance, Invoice_Received, Paid, Date_Paid FROM Contractor_Hours WHERE Contractor_Code = '" + CCODE + "'", conn);

                dt = new DataTable();
                da.Fill(dt);
            }

            decimal netTot   = new Decimal();
            decimal totHours = new Decimal();

            foreach (DataRow dr in dt.Rows)
            {
                if (dr["Final_Total"].ToString() != "")
                {
                    netTot += Convert.ToDecimal(dr["Final_Total"].ToString());
                }
                else
                {
                    netTot += Decimal.Zero;
                }
            }

            foreach (DataRow dr in dt.Rows)
            {
                if (dr["Hours"].ToString() != "")
                {
                    totHours += Convert.ToDecimal(dr["Hours"].ToString());
                }
                else
                {
                    totHours += Decimal.Zero;
                }
            }

            txt_C_TotPaid.Text  = netTot.ToString("c");
            txt_C_TotHours.Text = totHours.ToString();

            bs.DataSource = dt;
        }
        //================================================================================================================================================//
        // LOAD CLIENT DETAILS                                                                                                                            //
        //================================================================================================================================================//
        private void LoadClients()
        {
            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("SELECT * FROM Clients", conn);
                clientsDT = new DataTable();
                sqlDataAdapter.Fill(clientsDT);
            }

            if (clientsDT.Rows.Count > 0)
            {
                if (!btn_LIS_SelCli.Enabled)
                {
                    btn_LIS_SelCli.Enabled = true;
                }

                if (!dgv_LInvSent.Enabled)
                {
                    dgv_LInvSent.Enabled = true;
                }

                if (!btn_LIS_NewIS.Enabled)
                {
                    btn_LIS_NewIS.Enabled = true;
                }

                if (!btn_LIS_Filter.Enabled)
                {
                    btn_LIS_Filter.Enabled = true;
                }

                NUM_OF_CLIENTS     = clientsDT.Rows.Count - 1;
                txt_LIS_CCode.Text = clientsDT.Rows[CUR_CLIENT]["Code"].ToString().Trim();
                CNAME = clientsDT.Rows[CUR_CLIENT]["Name"].ToString().Trim();
                txt_LIS_CName.Text = CNAME;
            }
            else
            {
                btn_LIS_SelCli.Enabled = false;
                dgv_LInvSent.Enabled   = false;
                btn_LIS_NewIS.Enabled  = false;
                btn_LIS_Filter.Enabled = false;
            }
        }
        private void Btn_C_DoneAdd_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(new StringBuilder().Append("Are you sure you want to add contractor with Contractor Code: ").Append(txt_C_CCode.Text).Append("?").ToString(), "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (SqlConnection conn = DBUtils.GetDBConnection())
                {
                    conn.Open();

                    try
                    {
                        using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO Contractors VALUES (@CCode, @Name, @Surname, @EName, @EVN)", conn))
                        {
                            sqlCommand.Parameters.AddWithValue("@CCode", txt_C_CCode.Text.Trim());
                            sqlCommand.Parameters.AddWithValue("@Name", txt_C_Name.Text.Trim());
                            sqlCommand.Parameters.AddWithValue("@Surname", txt_C_Surname.Text.Trim());
                            sqlCommand.Parameters.AddWithValue("@EName", txt_C_EName.Text.Trim());
                            sqlCommand.Parameters.AddWithValue("@EVN", txt_C_EVN.Text.Trim());
                            sqlCommand.ExecuteNonQuery();

                            MessageBox.Show("New contractor successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }

                        LoadCon();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    finally
                    {
                        SetFieldsReadOnly();
                        ShowButtons();

                        btn_C_DoneAdd.Visible = false;
                    }
                }
            }
            else
            {
                SetFieldsReadOnly();
                ShowButtons();

                btn_C_DoneAdd.Visible = false;
            }
        }
        private void btn_LIS_Filter_Click(object sender, EventArgs e)
        {
            bs.Filter  = string.Empty;
            bs.Sort    = string.Empty;
            isFiltered = true;

            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("SELECT * FROM Invoices_Send WHERE Client LIKE '" + CNAME + "%' AND Date BETWEEN '" + dtp_LIS_From.Value + "' AND '" + dtp_LIS_To.Value + "' OR Client LIKE '" + CNAME + "%' AND Date_Paid BETWEEN '" + dtp_LIS_From.Value + "' AND '" + dtp_LIS_To.Value + "'", conn);
                dt = new DataTable();
                sqlDataAdapter.Fill(dt);
            }

            bs.DataSource               = (object)dt;
            btn_LIS_Filter.Visible      = false;
            btn_LIS_ClearFilter.Visible = true;
        }
        private void Btn_PAE_Filter_Click(object sender, EventArgs e)
        {
            bs.Filter  = string.Empty;
            bs.Sort    = string.Empty;
            isFiltered = true;

            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();
                SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Projects WHERE Date BETWEEN '" + dtp_PAE_From.Value + "' AND '" + dtp_PAE_To.Value + "'", conn);
                dt = new DataTable();
                da.Fill(dt);
            }

            bs.DataSource               = dt;
            btn_PAE_Filter.Visible      = false;
            btn_PAE_ClearFilter.Visible = true;
        }
        //================================================================================================================================================//
        // DONE CLICKED                                                                                                                                   //
        //================================================================================================================================================//
        private void Btn_QED_Done_Click(object sender, EventArgs e)
        {
            string qNum = txt_QED_QNum.Text;

            if (MessageBox.Show("Are you sure you want to update quote?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (SqlConnection conn = DBUtils.GetDBConnection())
                {
                    conn.Open();

                    try
                    {
                        using (SqlCommand sqlCommand = new SqlCommand("UPDATE Quotes_Send SET Date_Send = @Date, Quote_Description = @Desc, Order_Placed = @OPlaced WHERE Quote_Number = @QNum", conn))
                        {
                            sqlCommand.Parameters.AddWithValue("@Date", dtp_QED_Date.Value);
                            sqlCommand.Parameters.AddWithValue("@Desc", txt_QED_Desc.Text.Trim());

                            if (cb_QED_OrderPlaced.Checked)
                            {
                                sqlCommand.Parameters.AddWithValue("@OPlaced", "Yes");
                            }
                            else
                            {
                                sqlCommand.Parameters.AddWithValue("@OPlaced", "No");
                            }

                            sqlCommand.Parameters.AddWithValue("@QNum", qNum);
                            sqlCommand.ExecuteNonQuery();

                            MessageBox.Show("Quote successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Example #7
0
        //================================================================================================================================================//
        // DONE CLICKED                                                                                                                                   //
        //================================================================================================================================================//
        private void Btn_QA_Done_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder().Append("Are you sure you want to add quote with Quote Number: ").Append(txt_QA_QNum.Text).Append("?");

            if (MessageBox.Show(sb.ToString(), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (SqlConnection conn = DBUtils.GetDBConnection())
                {
                    conn.Open();
                    try
                    {
                        using (SqlCommand cmd = new SqlCommand("INSERT INTO Quotes_Send VALUES (@QNum, @Date, @Client, @Desc, @OPlaced)", conn))
                        {
                            cmd.Parameters.AddWithValue("@QNum", txt_QA_QNum.Text.Trim());
                            cmd.Parameters.AddWithValue("@Date", dtp_QA_Date.Value);
                            cmd.Parameters.AddWithValue("@Client", txt_QA_CName.Text.Trim());
                            cmd.Parameters.AddWithValue("@Desc", txt_QA_Desc.Text.Trim());

                            if (cb_QA_OrderPlaced.Checked)
                            {
                                cmd.Parameters.AddWithValue("@OPlaced", "Yes");
                            }
                            else
                            {
                                cmd.Parameters.AddWithValue("@OPlaced", "No");
                            }

                            cmd.ExecuteNonQuery();

                            MessageBox.Show("New quote successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Example #8
0
        //================================================================================================================================================//
        // LOAD CLIENT DETAILS                                                                                                                            //
        //================================================================================================================================================//
        private void LoadClients()
        {
            dt = new DataTable();

            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();

                SqlDataAdapter lClientDA = new SqlDataAdapter("SELECT * FROM Clients", conn);
                SqlDataAdapter iClientDA = new SqlDataAdapter("SELECT * FROM Int_Clients", conn);

                lClientDA.Fill(dt);
                iClientDA.Fill(dt);
            }

            foreach (DataRow dr in dt.Rows)
            {
                ddb_PA_CCode.AddItem(dr["Code"].ToString().Trim());
            }

            ddb_PA_CCode.selectedIndex = 0;
        }
Example #9
0
        //================================================================================================================================================//
        // DONE CLICKED                                                                                                                                   //
        //================================================================================================================================================//
        private void Btn_PA_Done_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder().Append("Are you sure you want to add project with project code: ").Append(txt_PA_ProjCode.Text).Append("?");

            if (MessageBox.Show(sb.ToString(), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (SqlConnection conn = DBUtils.GetDBConnection())
                {
                    conn.Open();
                    try
                    {
                        using (SqlCommand cmd = new SqlCommand("INSERT INTO Projects VALUES (@ProjID, @Date, @ClientCode, @ClientName, @Desc, @QNum)", conn))
                        {
                            cmd.Parameters.AddWithValue("@ProjID", txt_PA_ProjCode.Text.Trim());
                            cmd.Parameters.AddWithValue("@Date", dtp_PA_Date.Value);
                            cmd.Parameters.AddWithValue("@ClientCode", ddb_PA_CCode.selectedValue.Trim());
                            cmd.Parameters.AddWithValue("@ClientName", txt_PA_CName.Text.Trim());
                            cmd.Parameters.AddWithValue("@Desc", txt_PA_Desc.Text.Trim());
                            cmd.Parameters.AddWithValue("@QNum", txt_PA_QNum.Text.Trim());
                            cmd.ExecuteNonQuery();
                        }
                        using (SqlCommand cmd = new SqlCommand("INSERT INTO Quotes_Send(Quote_Number, Client) VALUES (@QNum, @Client)", conn))
                        {
                            cmd.Parameters.AddWithValue("@QNum", txt_PA_QNum.Text.Trim());
                            cmd.Parameters.AddWithValue("@Client", txt_PA_CName.Text.Trim());
                            cmd.ExecuteNonQuery();
                        }

                        MessageBox.Show("New project successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void Btn_C_Filter_Click(object sender, EventArgs e)
        {
            btn_C_Filter.Visible      = false;
            btn_C_ClearFilter.Visible = true;

            bs.Filter = string.Empty;
            bs.Sort   = string.Empty;

            isFiltered = true;

            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Contractor_Hours WHERE Contractor_Code = '" + CCODE + "' AND Date_Start BETWEEN '"
                                                       + dtp_C_From.Value + "' AND '" + dtp_C_To.Value + "' OR Date_End BETWEEN '" + dtp_C_From.Value + "' AND '" + dtp_C_To.Value + "'", conn);

                dt = new DataTable();
                da.Fill(dt);
            }

            bs.DataSource = dt;
        }
        //================================================================================================================================================//
        // LOAD CONTRACTOR DETAILS                                                                                                                        //
        //================================================================================================================================================//
        private void LoadCon()
        {
            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();

                SqlDataAdapter conDA = new SqlDataAdapter("SELECT * FROM Contractors", conn);
                conDA.Fill(conDT);
            }

            NUM_OF_CON = conDT.Rows.Count - 1;

            if (NUM_OF_CON == 0)
            {
                btn_C_Next.Enabled = false;
            }
            else if (NUM_OF_CON != 0 && !btn_C_Next.Enabled)
            {
                btn_C_Next.Enabled = true;
            }

            FillTextFields();
        }
Example #12
0
        //================================================================================================================================================//
        // DONE CLICKED                                                                                                                                   //
        //================================================================================================================================================//
        private void Btn_ISA_Done_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to add invoice with Invoice Number: " + txt_ISA_InvNum.Text + "?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                using (SqlConnection conn = DBUtils.GetDBConnection())
                {
                    conn.Open();

                    try
                    {
                        using (SqlCommand cmd = new SqlCommand("INSERT INTO Invoices_Send VALUES (@Date, @InvNum, @Client, @Desc, @Amt, @VAT, @Paid, @DatePaid)", conn))
                        {
                            decimal amt;
                            decimal VAT;

                            if (!isInter)
                            {
                                if (txt_ISA_Amt.Text.Contains("R"))
                                {
                                    if (txt_ISA_Amt.Text.Replace("R", string.Empty) == "0.00")
                                    {
                                        amt = 0.00m;
                                    }
                                    else
                                    {
                                        amt = Decimal.Parse(txt_ISA_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                    }
                                }
                                else
                                {
                                    amt = 0.00m;
                                }


                                if (txt_ISA_VAT.Text.Contains("R"))
                                {
                                    if (txt_ISA_VAT.Text.Replace("R", string.Empty) == "0.00")
                                    {
                                        VAT = 0.00m;
                                    }
                                    else
                                    {
                                        VAT = Decimal.Parse(txt_ISA_VAT.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                    }
                                }
                                else
                                {
                                    VAT = 0.00m;
                                }
                            }
                            else
                            {
                                if (txt_ISA_Amt.Text.Contains("$"))
                                {
                                    if (txt_ISA_Amt.Text.Replace("$", string.Empty) == "0.00")
                                    {
                                        amt = 0.00m;
                                    }
                                    else
                                    {
                                        amt = Decimal.Parse(txt_ISA_Amt.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                    }
                                }
                                else
                                {
                                    amt = 0.00m;
                                }


                                if (txt_ISA_VAT.Text.Contains("$"))
                                {
                                    if (txt_ISA_VAT.Text.Replace("$", string.Empty) == "0.00")
                                    {
                                        VAT = 0.00m;
                                    }
                                    else
                                    {
                                        VAT = Decimal.Parse(txt_ISA_VAT.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                    }
                                }
                                else
                                {
                                    VAT = 0.00m;
                                }
                            }

                            cmd.Parameters.AddWithValue("@Date", dtp_ISA_Date.Value);
                            cmd.Parameters.AddWithValue("@InvNum", txt_ISA_InvNum.Text.Trim());
                            cmd.Parameters.AddWithValue("@Client", txt_ISA_CName.Text.Trim());
                            cmd.Parameters.AddWithValue("@Desc", txt_ISA_Desc.Text.Trim());
                            cmd.Parameters.AddWithValue("@Amt", amt);
                            cmd.Parameters.AddWithValue("@VAT", VAT);

                            if (cb_ISA_Paid.Checked)
                            {
                                cmd.Parameters.AddWithValue("@Paid", "Yes");
                                cmd.Parameters.AddWithValue("@DatePaid", dtp_ISA_DatePaid.Value);
                            }
                            else
                            {
                                cmd.Parameters.AddWithValue("@Paid", "No");
                                cmd.Parameters.AddWithValue("@DatePaid", DBNull.Value);
                            }

                            cmd.ExecuteNonQuery();

                            MessageBox.Show("New invoice successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            if (!isInter)
                            {
                                parent.setNewInvoice(txt_ISA_InvNum.Text);
                            }
                            else
                            {
                                intParent.SetNewInvoice(txt_ISA_InvNum.Text);
                            }

                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Example #13
0
        //================================================================================================================================================//
        // BUTTON DONE CLICKED                                                                                                                                   //
        //================================================================================================================================================//
        private void Btn_HA_Done_Click(object sender, EventArgs e)
        {
            string code = txt_HA_Code.Text;

            if (send is Button)
            {
                StringBuilder sb = new StringBuilder().Append("Are you sure you want to add work week with Code: ").Append(code).Append("?");

                if (MessageBox.Show(sb.ToString(), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (SqlConnection conn = DBUtils.GetDBConnection())
                    {
                        conn.Open();
                        try
                        {
                            using (SqlCommand cmd = new SqlCommand("INSERT INTO Contractor_Hours VALUES (@Code, @Date_Start, @Date_End, @Hours, @RPHour, @TotBE, @ERate, @TotAE, @QTCut, @FTot, @Rem, @Inv, @Paid, @DPaid, @CCode)", conn))
                            {
                                decimal excRate;

                                if (txt_HA_ExcRate.Text == "0.00000")
                                {
                                    excRate = 0.00000m;
                                }
                                else
                                {
                                    excRate = Decimal.Parse(txt_HA_ExcRate.Text);
                                }

                                decimal perHour;
                                if (txt_HA_DolPH.Text.Contains("$"))
                                {
                                    if (txt_HA_DolPH.Text.Replace("$", string.Empty) == "0.00")
                                    {
                                        perHour = 0.00m;
                                    }
                                    else
                                    {
                                        perHour = Decimal.Parse(txt_HA_DolPH.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                    }
                                }
                                else
                                {
                                    perHour = 0.00m;
                                }

                                decimal totBE;
                                if (txt_HA_TotBE.Text.Replace("$", string.Empty) == "0.00")
                                {
                                    totBE = 0.00m;
                                }
                                else
                                {
                                    totBE = Decimal.Parse(txt_HA_TotBE.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                }

                                decimal qtCut;
                                if (txt_HA_QTCut.Text.Contains("R"))
                                {
                                    if (txt_HA_QTCut.Text.Replace("R", string.Empty) == "0.00")
                                    {
                                        qtCut = 0.00m;
                                    }
                                    else
                                    {
                                        qtCut = Decimal.Parse(txt_HA_QTCut.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                    }
                                }
                                else
                                {
                                    qtCut = 0.00m;
                                }

                                decimal totAE;
                                if (txt_HA_TotAE.Text.Replace("R", string.Empty) == "0.00")
                                {
                                    totAE = 0.00m;
                                }
                                else
                                {
                                    totAE = Decimal.Parse(txt_HA_TotAE.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                }

                                decimal fTot;
                                if (txt_HA_FTotal.Text.Replace("R", string.Empty) == "0.00")
                                {
                                    fTot = 0.00m;
                                }
                                else
                                {
                                    fTot = Decimal.Parse(txt_HA_FTotal.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                }

                                decimal hours;
                                if (txt_HA_HW.Text == string.Empty)
                                {
                                    hours = 0.00m;
                                }
                                else if (txt_HA_HW.Text.Contains("."))
                                {
                                    hours = Decimal.Parse(txt_HA_HW.Text.Replace(".", ","));
                                }
                                else
                                {
                                    hours = Decimal.Parse(txt_HA_HW.Text);
                                }

                                cmd.Parameters.AddWithValue("@Code", txt_HA_Code.Text.Trim());
                                cmd.Parameters.AddWithValue("@Date_Start", dtp_HA_From.Value);
                                cmd.Parameters.AddWithValue("@Date_End", dtp_HA_To.Value);
                                cmd.Parameters.AddWithValue("@Hours", hours);
                                cmd.Parameters.AddWithValue("@RPHour", perHour);
                                cmd.Parameters.AddWithValue("@TotBE", totBE);
                                cmd.Parameters.AddWithValue("@ERate", excRate);
                                cmd.Parameters.AddWithValue("@TotAE", totAE);
                                cmd.Parameters.AddWithValue("@QTCut", qtCut);
                                cmd.Parameters.AddWithValue("@FTot", fTot);
                                cmd.Parameters.AddWithValue("@Rem", "No");
                                cmd.Parameters.AddWithValue("@Inv", "No");

                                if (cb_HA_Paid.Checked)
                                {
                                    cmd.Parameters.AddWithValue("@Paid", "Yes");
                                    cmd.Parameters.AddWithValue("@DPaid", dtp_HA_DatePaid.Value);
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@Paid", "No");
                                    cmd.Parameters.AddWithValue("@DPaid", DBNull.Value);
                                }

                                cmd.Parameters.AddWithValue("@CCode", txt_HA_CCode.Text.Trim());
                                cmd.ExecuteNonQuery();

                                MessageBox.Show("New work week successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder().Append("Are you sure you want to update work week with Code: ").Append(code).Append("?");

                if (MessageBox.Show(sb.ToString(), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    DoUpdate();
                }
            }
        }
        //================================================================================================================================================//
        // LOAD EXPENSES                                                                                                                                  //
        //================================================================================================================================================//
        private void LoadExpenses()
        {
            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter("SELECT ID, Description, Travel, Accomodation, Subsistence, Tools, Programming_Hours, Install_Hours, "
                                                       + "Date, User_Log FROM Project_Expenses WHERE Project_ID = '" + Proj_ID + "'", conn);
                dt = new DataTable();
                da.Fill(dt);
            }

            decimal totRand  = 0.00m;
            decimal totDol   = 0.00m;
            decimal totHours = 0.00m;

            foreach (DataRow row in (InternalDataCollectionBase)dt.Rows)
            {
                if (row["Travel"].ToString() != "")
                {
                    if (row["Travel"].ToString().Contains("R"))
                    {
                        totRand += Convert.ToDecimal(row["Travel"].ToString().Remove(0, 1));
                    }
                    else if (row["Travel"].ToString().Contains("$"))
                    {
                        totDol += Convert.ToDecimal(row["Travel"].ToString().Remove(0, 1));
                    }
                }

                if (row["Accomodation"].ToString() != "")
                {
                    if (row["Accomodation"].ToString().Contains("R"))
                    {
                        totRand += Convert.ToDecimal(row["Accomodation"].ToString().Remove(0, 1));
                    }
                    else if (row["Accomodation"].ToString().Contains("$"))
                    {
                        totDol += Convert.ToDecimal(row["Accomodation"].ToString().Remove(0, 1));
                    }
                }

                if (row["Subsistence"].ToString() != "")
                {
                    if (row["Subsistence"].ToString().Contains("R"))
                    {
                        totRand += Convert.ToDecimal(row["Subsistence"].ToString().Remove(0, 1));
                    }
                    else if (row["Subsistence"].ToString().Contains("$"))
                    {
                        totDol += Convert.ToDecimal(row["Subsistence"].ToString().Remove(0, 1));
                    }
                }

                if (row["Tools"].ToString() != "")
                {
                    if (row["Tools"].ToString().Contains("R"))
                    {
                        totRand += Convert.ToDecimal(row["Tools"].ToString().Remove(0, 1));
                    }
                    else if (row["Tools"].ToString().Contains("$"))
                    {
                        totDol += Convert.ToDecimal(row["Tools"].ToString().Remove(0, 1));
                    }
                }

                if (row["Programming_Hours"].ToString() != "")
                {
                    totHours += Convert.ToDecimal(row["Programming_Hours"].ToString());
                }
                if (row["Install_Hours"].ToString() != "")
                {
                    totHours += Convert.ToDecimal(row["Install_Hours"].ToString());
                }
            }

            txt_PAE_TotRand.Text  = totRand.ToString("C");
            txt_PAE_TotDol.Text   = totDol.ToString("C", (IFormatProvider)CultureInfo.GetCultureInfo("en-US"));
            txt_PAE_TotHours.Text = totHours.ToString();

            bs.DataSource = dt;
        }
Example #15
0
        private void Btn_ISED_Done_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to update invoice?", "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();
                try
                {
                    using (SqlCommand cmd = new SqlCommand("UPDATE Invoices_Send SET Invoice_Number = @INum, Date = @Date, Description = @Desc, Total_Amount = @Amt, VAT = @VAT, Paid = @Paid, Date_Paid = @DPaid WHERE Invoice_Number = @oldINum", conn))
                    {
                        decimal amt;
                        decimal VAT;

                        if (!isInter)
                        {
                            if (txt_ISED_Amt.Text.Contains("R"))
                            {
                                if (txt_ISED_Amt.Text.Replace("R", string.Empty) == "0.00")
                                {
                                    amt = 0.00m;
                                }
                                else
                                {
                                    amt = Decimal.Parse(txt_ISED_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                }
                            }
                            else
                            {
                                amt = 0.00m;
                            }

                            if (txt_ISED_VAT.Text.Contains("R"))
                            {
                                if (txt_ISED_VAT.Text.Replace("R", string.Empty) == "0.00")
                                {
                                    VAT = 0.00m;
                                }
                                else
                                {
                                    VAT = Decimal.Parse(txt_ISED_VAT.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                }
                            }
                            else
                            {
                                VAT = 0.00m;
                            }
                        }
                        else
                        {
                            if (txt_ISED_Amt.Text.Contains("$"))
                            {
                                if (txt_ISED_Amt.Text.Replace("$", string.Empty) == "0.00")
                                {
                                    amt = 0.00m;
                                }
                                else
                                {
                                    amt = Decimal.Parse(txt_ISED_Amt.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                }
                            }
                            else
                            {
                                amt = 0.00m;
                            }

                            if (txt_ISED_VAT.Text.Contains("$"))
                            {
                                if (txt_ISED_VAT.Text.Replace("$", string.Empty) == "0.00")
                                {
                                    VAT = 0.00m;
                                }
                                else
                                {
                                    VAT = Decimal.Parse(txt_ISED_VAT.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                }
                            }
                            else
                            {
                                VAT = 0.00m;
                            }
                        }

                        cmd.Parameters.AddWithValue("@Date", dtp_ISED_Date.Value);
                        cmd.Parameters.AddWithValue("@Desc", txt_ISED_Desc.Text.Trim());
                        cmd.Parameters.AddWithValue("@Amt", amt);
                        cmd.Parameters.AddWithValue("@VAT", VAT);

                        if (cb_ISED_Paid.Checked)
                        {
                            cmd.Parameters.AddWithValue("@Paid", "Yes");
                            cmd.Parameters.AddWithValue("@DPaid", dtp_ISED_DatePaid.Value);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@Paid", "No");
                            cmd.Parameters.AddWithValue("@DPaid", DBNull.Value);
                        }

                        if (txt_ISED_INInst.Text == string.Empty)
                        {
                            cmd.Parameters.AddWithValue("@INum", txt_ISED_InvNum.Text.Trim());
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@INum", txt_ISED_InvNum.Text.Trim() + "." + txt_ISED_INInst.Text.Trim());
                        }

                        cmd.ExecuteNonQuery();

                        MessageBox.Show("Invoice successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        //================================================================================================================================================//
        // EDIT INVOICE DETAILS                                                                                                                           //
        //================================================================================================================================================//
        private void Btn_IRED_Done_Click(object sender, EventArgs e)
        {
            if (txt_IRED_InvNum.Text != string.Empty)
            {
                if (MessageBox.Show("Are you sure you want to update invoice?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (txt_IRED_InvNum.Text == oldINum)
                    {
                        using (SqlConnection conn = DBUtils.GetDBConnection())
                        {
                            conn.Open();
                            try
                            {
                                using (SqlCommand cmd = new SqlCommand("UPDATE Invoices_Received SET Date = @Date, Supplier = @Supp, Description = @Desc, Total_Amount = @Amt, VAT = @VAT, Paid = @Paid WHERE Invoice_Number = @INum", conn))
                                {
                                    decimal amt;
                                    if (txt_IRED_Amt.Text.Contains("R"))
                                    {
                                        if (txt_IRED_Amt.Text.Replace("R", string.Empty) == "0.00")
                                        {
                                            amt = 0.00m;
                                        }
                                        else
                                        {
                                            amt = Decimal.Parse(txt_IRED_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                        }
                                    }
                                    else
                                    {
                                        amt = 0.00m;
                                    }

                                    decimal VAT;
                                    if (txt_IRED_VAT.Text.Contains("R"))
                                    {
                                        if (txt_IRED_VAT.Text.Replace("R", string.Empty) == "0.00")
                                        {
                                            VAT = 0.00m;
                                        }
                                        else
                                        {
                                            VAT = Decimal.Parse(txt_IRED_VAT.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                        }
                                    }
                                    else
                                    {
                                        VAT = 0.00m;
                                    }

                                    cmd.Parameters.AddWithValue("@Date", dtp_IRED_Date.Value);
                                    cmd.Parameters.AddWithValue("@Supp", txt_IRED_SuppName.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Desc", txt_IRED_Desc.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Amt", amt);
                                    cmd.Parameters.AddWithValue("@VAT", VAT);

                                    if (cb_IRED_Paid.Checked)
                                    {
                                        cmd.Parameters.AddWithValue("@Paid", "Yes");
                                    }
                                    else
                                    {
                                        cmd.Parameters.AddWithValue("@Paid", "No");
                                    }

                                    cmd.Parameters.AddWithValue("@INum", txt_IRED_InvNum.Text.Trim());

                                    cmd.ExecuteNonQuery();

                                    MessageBox.Show("Invoice successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    this.Close();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else if (txt_IRED_InvNum.Text != oldINum)
                    {
                        using (SqlConnection conn = DBUtils.GetDBConnection())
                        {
                            conn.Open();
                            try
                            {
                                using (SqlCommand cmd = new SqlCommand("UPDATE Invoices_Received SET Date = @Date, Invoice_Number = @oldINum, Supplier = @Supp, Description = @Desc, Total_Amount = @Amt, VAT = @VAT, Paid = @Paid WHERE Invoice_Number = @INum", conn))
                                {
                                    decimal amt;
                                    if (txt_IRED_Amt.Text.Contains("R"))
                                    {
                                        if (txt_IRED_Amt.Text.Replace("R", string.Empty) == "0.00")
                                        {
                                            amt = 0.00m;
                                        }
                                        else
                                        {
                                            amt = Decimal.Parse(txt_IRED_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                        }
                                    }
                                    else
                                    {
                                        amt = 0.00m;
                                    }

                                    decimal VAT;
                                    if (txt_IRED_VAT.Text.Contains("R"))
                                    {
                                        if (txt_IRED_VAT.Text.Replace("R", string.Empty) == "0.00")
                                        {
                                            VAT = 0.00m;
                                        }
                                        else
                                        {
                                            VAT = Decimal.Parse(txt_IRED_VAT.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                        }
                                    }
                                    else
                                    {
                                        VAT = 0.00m;
                                    }

                                    cmd.Parameters.AddWithValue("@Date", dtp_IRED_Date.Value);
                                    cmd.Parameters.AddWithValue("@oldINum", txt_IRED_InvNum.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Supp", txt_IRED_SuppName.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Desc", txt_IRED_Desc.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Amt", amt);
                                    cmd.Parameters.AddWithValue("@VAT", VAT);

                                    if (cb_IRED_Paid.Checked)
                                    {
                                        cmd.Parameters.AddWithValue("@Paid", "Yes");
                                    }
                                    else
                                    {
                                        cmd.Parameters.AddWithValue("@Paid", "No");
                                    }

                                    cmd.Parameters.AddWithValue("@INum", oldINum);

                                    cmd.ExecuteNonQuery();

                                    MessageBox.Show("Invoice successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    this.Close();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter an Invoice Number to continue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #17
0
        //================================================================================================================================================//
        // CLIENT CODE SELECT                                                                                                                             //
        //================================================================================================================================================//
        private void Ddb_PA_CCode_onItemSelected(object sender, EventArgs e)
        {
            foreach (DataRow dr in dt.Rows)
            {
                if (dr["Code"].ToString().Trim().Equals(ddb_PA_CCode.selectedValue))
                {
                    txt_PA_CName.Text = dr["Name"].ToString().Trim();
                }
            }

            projDT = ((Projects)((Home)this.Owner).GetCurForm()).GetProjects();

            int CCode = 0;

            foreach (DataRow row in projDT.Rows)
            {
                string[] strArray = row["Project_ID"].ToString().Trim().Split('_');

                int x = 0;

                if (strArray[1].Equals(ddb_PA_CCode.selectedValue))
                {
                    x = Convert.ToInt32(strArray[0].Remove(0, 1));
                }

                if (x > CCode)
                {
                    CCode = x;
                }
            }

            txt_PA_ProjCode.Text = "P" + (CCode + 1).ToString("000") + "_" + ddb_PA_CCode.selectedValue;

            DataTable dataTable;

            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Quotes_Send WHERE Client = '" + txt_PA_CName.Text.Trim() + "'", conn);
                dataTable = new DataTable();
                da.Fill(dataTable);
            }

            int QNum = 1;

            foreach (DataRow dr in dataTable.Rows)
            {
                if (dr.RowState == DataRowState.Deleted)
                {
                    string str = dr["Quote_Number", DataRowVersion.Original].ToString().Trim();
                    int    pos = str.IndexOf("_");
                    int    x   = Convert.ToInt32(str.Remove(0, pos + 2));
                    if (x > QNum)
                    {
                        QNum = x;
                    }
                }
                else
                {
                    string str = dr["Quote_Number"].ToString().Trim();
                    int    pos = str.IndexOf("_");
                    int    x   = Convert.ToInt32(str.Remove(0, pos + 2));
                    if (x > QNum)
                    {
                        QNum = x;
                    }
                }
            }
            txt_PA_QNum.Text = ddb_PA_CCode.selectedValue + "_Q" + (QNum + 1).ToString("000");
        }
Example #18
0
        private void DoUpdate()
        {
            using (SqlConnection conn = DBUtils.GetDBConnection())
            {
                conn.Open();
                try
                {
                    using (SqlCommand cmd = new SqlCommand("UPDATE Contractor_Hours SET Date_Start = @DateS, Date_End = @DateE, Hours = @Hours, Rate_Per_Hour = @RPH, Total_$ = @TotBE, Exchange_Rate = @ER, Total_R = @TotAE, QTech_Cut = @QTC, Final_Total = @FTot, Paid = @P, Date_Paid = @DP WHERE Code = @Code", conn))
                    {
                        decimal excRate;

                        if (txt_HA_ExcRate.Text == "0,00000" || txt_HA_ExcRate.Text == "0.00000")
                        {
                            excRate = 0.00000m;
                        }
                        else
                        {
                            excRate = Decimal.Parse(txt_HA_ExcRate.Text.Replace(".", ","), CultureInfo.GetCultureInfo("en-ZA"));
                        }

                        decimal perHour;
                        if (txt_HA_DolPH.Text.Contains("$"))
                        {
                            if (txt_HA_DolPH.Text.Replace("$", string.Empty) == "0.00")
                            {
                                perHour = 0.00m;
                            }
                            else
                            {
                                perHour = Decimal.Parse(txt_HA_DolPH.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                            }
                        }
                        else
                        {
                            perHour = 0.00m;
                        }

                        decimal totBE;
                        if (txt_HA_TotBE.Text.Replace("$", string.Empty) == "0.00")
                        {
                            totBE = 0.00m;
                        }
                        else
                        {
                            totBE = Decimal.Parse(txt_HA_TotBE.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                        }

                        decimal qtCut;
                        if (txt_HA_QTCut.Text.Contains("R"))
                        {
                            if (txt_HA_QTCut.Text.Replace("R", string.Empty) == "0,00" || txt_HA_QTCut.Text.Replace("R", string.Empty) == "0.00")
                            {
                                qtCut = 0.00m;
                            }
                            else
                            {
                                qtCut = Decimal.Parse(txt_HA_QTCut.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                            }
                        }
                        else
                        {
                            qtCut = 0.00m;
                        }

                        decimal totAE;
                        if (txt_HA_TotAE.Text.Replace("R", string.Empty) == "0,00" || txt_HA_TotAE.Text.Replace("R", string.Empty) == "0.00")
                        {
                            totAE = 0.00m;
                        }
                        else
                        {
                            totAE = Decimal.Parse(txt_HA_TotAE.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                        }

                        decimal fTot;
                        if (txt_HA_FTotal.Text.Replace("R", string.Empty) == "0,00" || txt_HA_FTotal.Text.Replace("R", string.Empty) == "0.00")
                        {
                            fTot = 0.00m;
                        }
                        else
                        {
                            fTot = Decimal.Parse(txt_HA_FTotal.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                        }

                        decimal hours;
                        if (txt_HA_HW.Text == string.Empty)
                        {
                            hours = 0.00m;
                        }
                        else if (txt_HA_HW.Text.Contains("."))
                        {
                            hours = Decimal.Parse(txt_HA_HW.Text.Replace(".", ","));
                        }
                        else
                        {
                            hours = Decimal.Parse(txt_HA_HW.Text);
                        }

                        cmd.Parameters.AddWithValue("@Code", txt_HA_Code.Text.Trim());
                        cmd.Parameters.AddWithValue("@DateS", dtp_HA_From.Value);
                        cmd.Parameters.AddWithValue("@DateE", dtp_HA_To.Value);
                        cmd.Parameters.AddWithValue("@Hours", hours);
                        cmd.Parameters.AddWithValue("@RPH", perHour);
                        cmd.Parameters.AddWithValue("@TotBE", totBE);
                        cmd.Parameters.AddWithValue("@ER", excRate);
                        cmd.Parameters.AddWithValue("@TotAE", totAE);
                        cmd.Parameters.AddWithValue("@QTC", qtCut);
                        cmd.Parameters.AddWithValue("@FTot", fTot);

                        if (cb_HA_Paid.Checked)
                        {
                            cmd.Parameters.AddWithValue("@P", "Yes");
                            cmd.Parameters.AddWithValue("@DP", dtp_HA_DatePaid.Value);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@P", "No");
                            cmd.Parameters.AddWithValue("@DP", DBNull.Value);
                        }

                        cmd.ExecuteNonQuery();

                        MessageBox.Show("Work week successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #19
0
        private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                app = new Microsoft.Office.Interop.Word.Application();
                doc = null;

                backgroundWorker1.ReportProgress(10);

                object fileName = @"\\192.168.8.121\Contractors\Remittances\Remittance_Template.docx";
                missing = Type.Missing;

                backgroundWorker1.ReportProgress(20);

                doc = app.Documents.Open(fileName, missing, missing);
                app.Selection.Find.ClearFormatting();
                app.Selection.Find.Replacement.ClearFormatting();

                backgroundWorker1.ReportProgress(30);

                app.Selection.Find.Execute("<code>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_Code.Text.Trim(), 2);
                app.Selection.Find.Execute("<name>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_Name.Text.Trim(), 2);
                app.Selection.Find.Execute("<surname>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_Surname.Text.Trim(), 2);

                backgroundWorker1.ReportProgress(40);

                app.Selection.Find.Execute("<date>", missing, missing, missing, missing, missing, missing, missing, missing, DateTime.Now.ToShortDateString(), 2);
                app.Selection.Find.Execute("<desc>", missing, missing, missing, missing, missing, missing, missing, missing, "Week ending " + dtp_HA_To.Value.ToLongDateString(), 2);
                app.Selection.Find.Execute("<dolvalue>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_TotBE.Text.Trim(), 2);
                app.Selection.Find.Execute("<excrate>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_ExcRate.Text.Trim(), 2);

                backgroundWorker1.ReportProgress(50);

                app.Selection.Find.Execute("<total>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_TotAE.Text.Trim(), 2);
                app.Selection.Find.Execute("<subtotal>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_TotAE.Text.Trim(), 2);
                app.Selection.Find.Execute("<grandtotal>", missing, missing, missing, missing, missing, missing, missing, missing, txt_HA_TotAE.Text.Trim(), 2);

                backgroundWorker1.ReportProgress(60);

                object SaveAsFile = (object)@"\\192.168.8.121\Contractors\Remittances\Remittance_" + txt_HA_Code.Text.Trim() + ".docx";
                doc.SaveAs2(SaveAsFile, missing, missing, missing);

                using (SqlConnection conn = DBUtils.GetDBConnection())
                {
                    backgroundWorker1.ReportProgress(70);

                    conn.Open();

                    string sql = "UPDATE Contractor_Hours SET Remittance=@Rem WHERE Code=@Code AND Contractor_Code=@CCode";

                    backgroundWorker1.ReportProgress(80);

                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.Parameters.AddWithValue("@Rem", "Yes");
                        cmd.Parameters.AddWithValue("@Code", txt_HA_Code.Text.Trim());

                        backgroundWorker1.ReportProgress(90);

                        cmd.Parameters.AddWithValue("@CCode", txt_HA_CCode.Text.Trim());

                        cmd.ExecuteNonQuery();
                    }
                }

                backgroundWorker1.ReportProgress(100);
            }
            catch (Exception ex)
            {
                error   = ex.Message;
                isError = true;
            }
        }
Example #20
0
        //================================================================================================================================================//
        // BUTTON DONE CLICKED                                                                                                                            //
        //================================================================================================================================================//
        private void Btn_IRA_Done_Click(object sender, EventArgs e)
        {
            string newINum = txt_IRA_InvNum.Text;

            sb = new StringBuilder().Append("Are you sure you want to add invoice with Invoice Number: ").Append(newINum).Append("?");

            if (newINum != string.Empty)
            {
                if (MessageBox.Show(sb.ToString(), "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    using (SqlConnection conn = DBUtils.GetDBConnection())
                    {
                        conn.Open();

                        try
                        {
                            using (SqlCommand cmd = new SqlCommand("INSERT INTO Invoices_Received VALUES (@Date, @InvNum, @Supp, @Desc, @Amt, @VAT, @Paid)", conn))
                            {
                                decimal amt;
                                if (txt_IRA_Amt.Text.Contains("R"))
                                {
                                    if (txt_IRA_Amt.Text.Replace("R", string.Empty) == "0.00")
                                    {
                                        amt = 0.00m;
                                    }
                                    else
                                    {
                                        amt = Decimal.Parse(txt_IRA_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                    }
                                }
                                else
                                {
                                    amt = 0.00m;
                                }

                                decimal VAT;
                                if (txt_IRA_VAT.Text.Contains("R"))
                                {
                                    if (txt_IRA_VAT.Text.Replace("R", string.Empty) == "0.00")
                                    {
                                        VAT = 0.00m;
                                    }
                                    else
                                    {
                                        VAT = Decimal.Parse(txt_IRA_VAT.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                    }
                                }
                                else
                                {
                                    VAT = 0.00m;
                                }

                                cmd.Parameters.AddWithValue("@Date", dtp_IRA_Date.Value);
                                cmd.Parameters.AddWithValue("@InvNum", txt_IRA_InvNum.Text.Trim());
                                cmd.Parameters.AddWithValue("@Supp", txt_IRA_SuppName.Text.Trim());
                                cmd.Parameters.AddWithValue("@Desc", txt_IRA_Desc.Text.Trim());
                                cmd.Parameters.AddWithValue("@Amt", amt);
                                cmd.Parameters.AddWithValue("@VAT", VAT);

                                if (cb_IRA_Paid.Checked)
                                {
                                    cmd.Parameters.AddWithValue("@Paid", "Yes");
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@Paid", "No");
                                }

                                cmd.ExecuteNonQuery();

                                MessageBox.Show("New invoice successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                this.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter an Invoice Number to continue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        //================================================================================================================================================//
        // EDIT ORDER DETAILS                                                                                                                             //
        //================================================================================================================================================//
        private void Btn_OED_Done_Click(object sender, EventArgs e)
        {
            if (txt_OED_CONum.Text != string.Empty)
            {
                if (MessageBox.Show("Are you sure you want to update order?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (txt_OED_CONum.Text.Trim() == oldCONum)
                    {
                        using (SqlConnection conn = DBUtils.GetDBConnection())
                        {
                            conn.Open();

                            try
                            {
                                string sql = "UPDATE Orders_Received SET Date = @Date, Description = @Desc, Amount = @Amt, Percentage_Invoiced = @PercInv, " +
                                             "Percentage_Received = @PercRec, Quote_Number = @QNum WHERE Client_Order_Number = @CONum";

                                using (SqlCommand cmd = new SqlCommand(sql, conn))
                                {
                                    decimal amt;

                                    if (isInter)
                                    {
                                        if (txt_OED_Amt.Text.Contains("$"))
                                        {
                                            if (txt_OED_Amt.Text.Replace("$", string.Empty) == "0.00")
                                            {
                                                amt = 0.00m;
                                            }
                                            else
                                            {
                                                amt = Decimal.Parse(txt_OED_Amt.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                            }
                                        }
                                        else
                                        {
                                            amt = 0.00m;
                                        }
                                    }
                                    else
                                    {
                                        if (txt_OED_Amt.Text.Contains("R"))
                                        {
                                            if (txt_OED_Amt.Text.Replace("R", string.Empty) == "0.00")
                                            {
                                                amt = 0.00m;
                                            }
                                            else
                                            {
                                                amt = Decimal.Parse(txt_OED_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                            }
                                        }
                                        else
                                        {
                                            amt = 0.00m;
                                        }
                                    }

                                    cmd.Parameters.AddWithValue("@Date", dtp_OED_Date.Value);
                                    cmd.Parameters.AddWithValue("@Desc", txt_OED_Desc.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Amt", amt);
                                    cmd.Parameters.AddWithValue("@PercInv", pInv);
                                    cmd.Parameters.AddWithValue("@PercRec", pRec);
                                    cmd.Parameters.AddWithValue("@QNum", txt_OED_QNum.Text.Trim());
                                    cmd.Parameters.AddWithValue("@CONum", oldCONum);

                                    cmd.ExecuteNonQuery();

                                    MessageBox.Show("Order successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    this.Close();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else if (txt_OED_CONum.Text.Trim() != oldCONum)
                    {
                        using (SqlConnection conn = DBUtils.GetDBConnection())
                        {
                            conn.Open();

                            try
                            {
                                string sql = "UPDATE Orders_Received SET Client_Order_Number = @CONum, Date = @Date, Description = @Desc, Amount = @Amt, Percentage_Invoiced = @PercInv, " +
                                             "Percentage_Received = @PercRec, Quote_Number = @QNum WHERE Client_Order_Number = @oldCONum";

                                using (SqlCommand cmd = new SqlCommand(sql, conn))
                                {
                                    decimal amt;

                                    if (isInter)
                                    {
                                        if (txt_OED_Amt.Text.Contains("$"))
                                        {
                                            if (txt_OED_Amt.Text.Replace("$", string.Empty) == "0.00")
                                            {
                                                amt = 0.00m;
                                            }
                                            else
                                            {
                                                amt = Decimal.Parse(txt_OED_Amt.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                            }
                                        }
                                        else
                                        {
                                            amt = 0.00m;
                                        }
                                    }
                                    else
                                    {
                                        if (txt_OED_Amt.Text.Contains("R"))
                                        {
                                            if (txt_OED_Amt.Text.Replace("R", string.Empty) == "0.00")
                                            {
                                                amt = 0.00m;
                                            }
                                            else
                                            {
                                                amt = Decimal.Parse(txt_OED_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                            }
                                        }
                                        else
                                        {
                                            amt = 0.00m;
                                        }
                                    }

                                    cmd.Parameters.AddWithValue("@CONum", txt_OED_CONum.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Date", dtp_OED_Date.Value);
                                    cmd.Parameters.AddWithValue("@Desc", txt_OED_Desc.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Amt", amt);
                                    cmd.Parameters.AddWithValue("@PercInv", pInv);
                                    cmd.Parameters.AddWithValue("@PercRec", pRec);
                                    cmd.Parameters.AddWithValue("@QNum", txt_OED_QNum.Text.Trim());
                                    cmd.Parameters.AddWithValue("@oldCONum", oldCONum);

                                    cmd.ExecuteNonQuery();

                                    MessageBox.Show("Order successfully updated.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    this.Close();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter a Client Order Number to continue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #22
0
        //================================================================================================================================================//
        // BUTTON DONE CLICKED                                                                                                                            //
        //================================================================================================================================================//
        private void Btn_OA_Done_Click(object sender, EventArgs e)
        {
            string newCONum = txt_OA_CONum.Text;

            sb = new StringBuilder().Append("Are you sure you want to add order with Client Order Number: ").Append(newCONum).Append("?");

            if (newCONum != string.Empty)
            {
                if (MessageBox.Show(sb.ToString(), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (SqlConnection conn = DBUtils.GetDBConnection())
                    {
                        conn.Open();
                        try
                        {
                            using (SqlCommand cmd = new SqlCommand("INSERT INTO Orders_Received VALUES (@Date, @Client, @CONum, @Desc, @Amt, @PercInv, @PercRec, @QNum)", conn))
                            {
                                decimal amt;

                                if (isInter)
                                {
                                    if (txt_OA_Amt.Text.Contains("$"))
                                    {
                                        if (txt_OA_Amt.Text.Replace("$", string.Empty) == "0.00")
                                        {
                                            amt = 0.00m;
                                        }
                                        else
                                        {
                                            amt = Decimal.Parse(txt_OA_Amt.Text.Replace("$", string.Empty), CultureInfo.GetCultureInfo("en-US"));
                                        }
                                    }
                                    else
                                    {
                                        amt = 0.00m;
                                    }
                                }
                                else
                                {
                                    if (txt_OA_Amt.Text.Contains("R"))
                                    {
                                        if (txt_OA_Amt.Text.Replace("R", string.Empty) == "0.00")
                                        {
                                            amt = 0.00m;
                                        }
                                        else
                                        {
                                            amt = Decimal.Parse(txt_OA_Amt.Text.Replace("R", string.Empty), CultureInfo.GetCultureInfo("en-ZA"));
                                        }
                                    }
                                    else
                                    {
                                        amt = 0.00m;
                                    }
                                }

                                cmd.Parameters.AddWithValue("@Date", dtp_OA_Date.Value);
                                cmd.Parameters.AddWithValue("@Client", txt_OA_CName.Text.Trim());
                                cmd.Parameters.AddWithValue("@CONum", txt_OA_CONum.Text.Trim());
                                cmd.Parameters.AddWithValue("@Desc", txt_OA_Desc.Text.Trim());
                                cmd.Parameters.AddWithValue("@Amt", amt);
                                cmd.Parameters.AddWithValue("@PercInv", pInv);
                                cmd.Parameters.AddWithValue("@PercRec", pRec);
                                cmd.Parameters.AddWithValue("@QNum", txt_OA_QNum.Text.Trim());

                                cmd.ExecuteNonQuery();

                                MessageBox.Show("New order successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                this.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter a Client Order Number to continue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #23
0
        private void DoAdd()
        {
            if (!txt_NE_User.Text.Equals(string.Empty))
            {
                if (MessageBox.Show(new StringBuilder().Append("Are you sure you want to add new line?").ToString(), "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (SqlConnection conn = DBUtils.GetDBConnection())
                    {
                        conn.Open();
                        try
                        {
                            using (SqlCommand cmd = new SqlCommand("INSERT INTO Project_Expenses VALUES (@ProjID, @Desc, @Travel, @Acc, @Sub, @Tools, @ProgHrs, @InstHrs, @Date, @User)", conn))
                            {
                                cmd.Parameters.AddWithValue("@ProjID", Proj_ID);
                                cmd.Parameters.AddWithValue("@Desc", txt_NE_Desc.Text.Trim());

                                if (ddb_NE_Column.selectedValue.Equals("Travel"))
                                {
                                    cmd.Parameters.AddWithValue("@Travel", txt_NE_Val.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Acc", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Sub", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Tools", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@ProgHrs", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@InstHrs", DBNull.Value);
                                }
                                else if (ddb_NE_Column.selectedValue.Equals("Accomodation"))
                                {
                                    cmd.Parameters.AddWithValue("@Travel", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Acc", txt_NE_Val.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Sub", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Tools", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@ProgHrs", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@InstHrs", DBNull.Value);
                                }
                                else if (ddb_NE_Column.selectedValue.Equals("Subsistence"))
                                {
                                    cmd.Parameters.AddWithValue("@Travel", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Acc", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Sub", txt_NE_Val.Text.Trim());
                                    cmd.Parameters.AddWithValue("@Tools", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@ProgHrs", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@InstHrs", DBNull.Value);
                                }
                                else if (ddb_NE_Column.selectedValue.Equals("Tools"))
                                {
                                    cmd.Parameters.AddWithValue("@Travel", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Acc", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Sub", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Tools", txt_NE_Val.Text.Trim());
                                    cmd.Parameters.AddWithValue("@ProgHrs", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@InstHrs", DBNull.Value);
                                }
                                else if (ddb_NE_Column.selectedValue.Equals("Programming_Hours"))
                                {
                                    cmd.Parameters.AddWithValue("@Travel", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Acc", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Sub", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Tools", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@ProgHrs", txt_NE_Val.Text.Trim());
                                    cmd.Parameters.AddWithValue("@InstHrs", DBNull.Value);
                                }
                                else if (ddb_NE_Column.selectedValue.Equals("Install_Hours"))
                                {
                                    cmd.Parameters.AddWithValue("@Travel", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Acc", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Sub", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@Tools", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@ProgHrs", DBNull.Value);
                                    cmd.Parameters.AddWithValue("@InstHrs", txt_NE_Val.Text.Trim());
                                }

                                cmd.Parameters.AddWithValue("@Date", DateTime.Now.Date);
                                cmd.Parameters.AddWithValue("@User", txt_NE_User.Text.Trim());
                                cmd.ExecuteNonQuery();

                                MessageBox.Show("New line successfully added.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Close();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter name in user field.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }