Exemplo n.º 1
0
 public ContractInformation(int length, int package, OwnerInformation ownerInfo, BusinessInformation businessInfo)
 {
     ContractLength      = length;
     ContractPackage     = package;
     GymOwnerInformation = ownerInfo;
     GymInformation      = businessInfo;
 }
Exemplo n.º 2
0
        private void CreateContract(string template)
        {
            //construct data
            OwnerInformation    owner = new OwnerInformation(directorName.Text, directorSurname.Text, directorMail.Text, directorPhone.Text);
            BusinessInformation businessInformation = new BusinessInformation(companyNameTextbox.Text, companyAddress.Text, companyCityTextbox.Text, companyPIBTextbox.Text, companyRegistryTextbox.Text, dinarskiTextbox.Text, devizniTextbox.Text);
            ContractInformation contractInfo        = new ContractInformation(contractLengthCombobox.SelectedIndex + 1, packageCombobox.SelectedIndex, owner, businessInformation);
            string contractNumber = DateTime.Now.ToString("MMddyyyymmssf");

            contractInfo.ContractNumber = contractNumber;

            Document doc = new Document();

            doc.LoadFromFile(template);
            doc.Replace("@companyName", contractInfo.GymInformation.Name, true, true);
            doc.Replace("@directorName", contractInfo.GymOwnerInformation.Name, true, true);
            doc.Replace("@directorSurname", contractInfo.GymOwnerInformation.Surname, true, true);
            doc.Replace("@companyCity", contractInfo.GymInformation.City, true, true);
            doc.Replace("@companyAddress", contractInfo.GymInformation.Address, true, true);
            doc.Replace("@PIB", contractInfo.GymInformation.PIB, true, true);
            doc.Replace("@companyRegistryNumber", contractInfo.GymInformation.RegistryNumber, true, true);
            doc.Replace("@dinarski", contractInfo.GymInformation.Dinarski, true, true);
            doc.Replace("@devizni", contractInfo.GymInformation.Devizni, true, true);
            doc.Replace("@directorNumber", contractInfo.GymOwnerInformation.Mobile, true, true);
            doc.Replace("@dateOfSigning", DateTime.Now.ToShortDateString(), true, true);
            doc.Replace("@package", (contractInfo.ContractPackage == 0) ? "Po iskoriscenosti" : "Flat fee", true, true);
            doc.Replace("@duration", contractInfo.ContractLength.ToString(), true, true);
            doc.Replace("@contractNumber", contractInfo.ContractNumber, true, true);
            doc.SaveToFile(contractNumber + ".docx");

            ProcessStartInfo info = new ProcessStartInfo(contractNumber + ".docx");

            Process.Start(info);
        }
Exemplo n.º 3
0
        public List <ContractInformation> GetAllContracts()
        {
            List <ContractInformation> toReturn = new List <ContractInformation>();

            using (var conn = GetConnection())
            {
                conn.Open();

                using (var com = new MySqlCommand("SELECT * FROM contracts INNER JOIN business ON contracts.business_id = business.business_id INNER JOIN owners ON business.owner_id = owners.owner_id", conn))
                {
                    using (var reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            BusinessInformation businessInfo = new BusinessInformation(reader.GetString(8), reader.GetString(9), reader.GetString(10), reader.GetString(11), reader.GetString(12), reader.GetString(13), reader.GetString(14));
                            OwnerInformation    ownerInfo    = new OwnerInformation(reader.GetString(16), reader.GetString(17), reader.GetString(18), reader.GetString(19));
                            ContractInformation contractInfo = new ContractInformation(reader.GetInt32(1), reader.GetInt32(2), ownerInfo, businessInfo);
                            contractInfo.ContractNumber = reader.GetString(4);

                            if (!reader.IsDBNull(5))
                            {
                                contractInfo.DateSigned = reader.GetDateTime(5);
                            }
                            toReturn.Add(contractInfo);
                        }
                    }
                }
            }
            return(toReturn);
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            //construct data
            OwnerInformation    owner = new OwnerInformation(directorName.Text, directorSurname.Text, directorMail.Text, directorPhone.Text);
            BusinessInformation businessInformation = new BusinessInformation(companyNameTextbox.Text, companyAddress.Text, companyCityTextbox.Text, companyPIBTextbox.Text, companyRegistryTextbox.Text, dinarskiTextbox.Text, devizniTextbox.Text);
            ContractInformation contractInfo        = new ContractInformation(contractLengthCombobox.SelectedIndex + 1, packageCombobox.SelectedIndex, owner, businessInformation);
            string contractNumber = DateTime.Now.ToString("MMddyyyymmssf");

            contractInfo.ContractNumber = contractNumber;
            //upload to the database

            Form1.AllContracts.Add(contractInfo);
            //save locally
            FileStream      fs = new FileStream("contracts.dat", FileMode.Create, FileAccess.Write);
            BinaryFormatter bf = new BinaryFormatter();

            bf.Serialize(fs, Form1.AllContracts);
            fs.Close();

            if (Database.Instance.CanConnect())
            {
                Database.Instance.InsertContract(contractInfo);
            }
            else
            {
                if (Form1.SyncTree == null)
                {
                    Form1.SyncTree = new List <SyncAction>();
                }

                SyncAction syncAction = new SyncAction {
                    Operation = "INSERT", ObjectValue = contractInfo
                };
                Form1.SyncTree.Add(syncAction);
                FileStream      fsSync = new FileStream("syncdata.syn", FileMode.Create, FileAccess.Write);
                BinaryFormatter bfSync = new BinaryFormatter();
                bfSync.Serialize(fsSync, Form1.SyncTree);
                fsSync.Close();
            }
        }