Esempio n. 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text.Length == 0)
            {
                MessageBox.Show("Please select a type of claim.");
                return;
            }
            if (distanceNum.Value == 0 || destinationText.Text.Length == 0 || reasonText.Text.Length == 0)
            {
                MessageBox.Show("Insufficient information.");
                return;
            }

            Database.Command("INSERT INTO travellingclaims(entryDate, numericValue, descriptionValue, reason, cost, `type`, employeeID) " +
                "VALUES(" + entryDate.Value.ToString("yyyyMMdd") + "," + distanceNum.Value + ",'" + clsFunctions.fixApostrophes(destinationText.Text) +
                    "','" + clsFunctions.fixApostrophes(reasonText.Text) + "'," +
                    (comboBox1.Text.Contains("Travel")?
                    String.Format("{0:F2}", priceNum.Value * distanceNum.Value):
                    String.Format("{0:F2}",distanceNum.Value)) +
                    ",'" + comboBox1.Text + "'," + employeeID + ")");
            clsFunctions.WriteLog("New " + comboBox1.Text + " claim submitted for " + employeeCombo.Text);
            distanceNum.Value = 0;
            destinationText.Clear();
            reasonText.Clear();

            var id = Database.Retrieve("travellingClaims", "entryDate = " + entryDate.Value.ToString("yyyyMMdd") + " AND employeeID = " + employeeID +
                " ORDER BY id Desc LIMIT 1", "id");
            var theRow = Database.Query("SELECT * FROM travellingClaims tc JOIN employees e on e.id = tc.EmployeeId WHERE tc.id = " +
                 id);

            //theRow.WriteXml(@"C:\LAD_DATA_DUMP\singleTravelClaim.xml", XmlWriteMode.WriteSchema);
            var Report = new Reports.rptTravelClaimSingle();
            Report.DataSource = theRow;
            Report.headerLabel.Text = comboBox1.Text;

            FileInfo exportFile = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tempClaim" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".rtf");
            var stream = exportFile.Create();
            Report.ExportToRtf(stream);
            stream.Close();
            var email = Database.Retrieve("travellingClaimTypes", "Name = '" + comboBox1.Text + "'", "emailAddress");
            clsFunctions.SendEmailAttachment(email,
                comboBox1.Text + " : " + employeeCombo.Text, "Please find attached claim", exportFile);
            //exportFile.Delete();
            loadEntries();
        }
Esempio n. 2
0
        private void approveButton_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text.Contains("Marketing"))
            {
                var colleges = Database.Retrieve("division", "divisionName");
                ArrayList myList = new ArrayList();

                foreach (DataRow theRows in colleges.Tables[0].Rows)
                {
                    myList.Add(theRows["divisionName"]);
                }
                frmSelectSingle myForm = new frmSelectSingle("Select College","Select college to reflect on marketing budget",myList);
                myForm.ShowDialog();
                if (myForm.Selection == "***") return;
                DateTime entrydate = new DateTime();
                var split = entryList.FocusedItem.Text.Split(new char[] { '/' });
                if (!DateTime.TryParse(split[1] + "/" + split[0] + "/" + split[2], out entrydate) || entrydate.ToString("dd/MM/yyyy") != entryList.FocusedItem.Text)
                {
                   // MessageBox.Show("Date was not detected properly from the first method.");
                    DateTime.TryParse(split[0] + "/" + split[1] + "/" + split[2], out entrydate);
                    //MessageBox.Show("Date now detected as " + entrydate.ToString("dd/MM/yyyy"));
                }
                else
                {
                    //MessageBox.Show("Date WAS detected properly from the first method.");
                }

                Database.Command("INSERT INTO marketingentries(division, entryDate,details1,details2,cost,marketingTypeID,`status`) VALUES('" +
                    clsFunctions.GetDivisionAbrev(myForm.Selection) + "'," + entrydate.ToString("yyyyMMdd") +
                    ",'" + destinationText.Text + "','" + reasonText.Text + "'," + entryList.FocusedItem.SubItems[4].Text +
                    "," + Database.Retrieve("marketingTypes", "Name = '" + comboBox1.Text.Replace("Marketing ","") + "'", "id") + ",'Planned')");
            }

            entryList.FocusedItem.SubItems[5].Text = "Approved";
            Database.Command("UPDATE travellingclaims SET approved = 'Approved' WHERE id = " + entryList.FocusedItem.SubItems[6].Text);
            var theRow = Database.Query("SELECT * FROM travellingClaims tc JOIN employees e on e.id = tc.EmployeeId WHERE tc.id = " +
                 entryList.FocusedItem.SubItems[6].Text);

            //theRow.WriteXml(@"C:\LAD_DATA_DUMP\singleTravelClaim.xml", XmlWriteMode.WriteSchema);
            var Report = new Reports.rptTravelClaimSingle();
            Report.headerLabel.Text = comboBox1.Text;
            Report.DataSource = theRow;
            FileInfo exportFile = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tempClaim" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".rtf");
            var stream = exportFile.Create();
            Report.ExportToRtf(stream);
            stream.Close();

            clsFunctions.SendEmailAttachment("*****@*****.**",
                "Approved " + comboBox1.Text + " : " + employeeCombo.Text, "Please find attached Travel Claim", exportFile);
            clsFunctions.WriteLog(comboBox1.Text + " Approved for " + employeeCombo.Text);
            //exportFile.Delete();
            loadEntries();
        }
Esempio n. 3
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            var theRow = Database.Query("SELECT * FROM travellingClaims tc JOIN employees e on e.id = tc.EmployeeId WHERE tc.id = " +
                entryList.FocusedItem.SubItems[6].Text);

            //theRow.WriteXml(@"C:\LAD_DATA_DUMP\singleTravelClaim.xml", XmlWriteMode.WriteSchema);
            var Report = new Reports.rptTravelClaimSingle();
            Report.DataSource = theRow;
            FileInfo exportFile = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tempClaim" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".rtf");
            var stream = exportFile.Create();
            Report.ExportToRtf(stream);
            stream.Close();

            clsFunctions.SendEmailAttachment(Database.Retrieve("travellingClaimTypes","name = '" + comboBox1.Text + "'","emailAddress"),
                comboBox1.Text + employeeCombo.Text, "Please find attached Employee Claim", exportFile);
            //exportFile.Delete();
            MessageBox.Show("Your claim has been sent for Approval.");
        }
Esempio n. 4
0
        private void printSingleButton_Click(object sender, EventArgs e)
        {
            if (entryList.FocusedItem == null)
            {
                MessageBox.Show("Please select a claim to print first.");
                return;
            }
            var theRow = Database.Query("SELECT * FROM travellingClaims tc JOIN employees e on e.id = tc.EmployeeId WHERE tc.id = " +
                entryList.FocusedItem.SubItems[6].Text);

            //theRow.WriteXml(@"C:\LAD_DATA_DUMP\singleTravelClaim.xml", XmlWriteMode.WriteSchema);
            var Report = new Reports.rptTravelClaimSingle();
            Report.headerLabel.Text = comboBox1.Text;
            Report.DataSource = theRow;
            Report.ShowPreviewDialog();
        }