public usrImportBank()
        {
            InitializeComponent();
            List <Building> buildingList = new Buildings(false).buildings;

            buildings = new Dictionary <string, Building>();
            foreach (Building b in buildingList)
            {
                buildings.Add(b.Abbr, b);
            }
            trustPeriod = Methods.getPeriod(DateTime.Now);
            dh          = new SqlDataHandler();
        }
        //private String getDebtorEmail(int buildingId)
        //{
        //    List<Building> testBuildings = new Buildings(false).buildings;
        //    var b = testBuildings.Where(a => a.Bu)
        //    String dEmail = "";
        //    foreach (Building b in testBuildings)
        //    {
        //        if (b.Name == buildingName) { dEmail = b.Debtor; }
        //    }
        //    return (dEmail != "" ? dEmail : Controller.user.email);
        //}

        private void SetBuildingStatement(String buildingName)
        {
            List <Building> testBuildings = new Buildings(false).buildings;
            int             buildingID    = 0;

            foreach (Building b in testBuildings)
            {
                if (b.Name == buildingName)
                {
                    buildingID = b.ID;
                    String query = "IF NOT EXISTS(SELECT id FROM tblDebtors WHERE buildingID = " + b.ID.ToString() + " AND completeDate = '" + DateTime.Now.ToString("yyyy/MM/dd") + "')";
                    query += " INSERT INTO tblDebtors(buildingID, completeDate, stmtprintemail) VALUES(" + b.ID.ToString() + ", '" + DateTime.Now.ToString("yyyy/MM/dd") + "', 'True')";
                    dh.SetData(query, null, out status);
                    break;
                }
            }
        }
        public usrIndStatements()
        {
            InitializeComponent();
            List <Building> allBuildings = new Buildings(false).buildings;

            buildings = new List <Building>();
            foreach (int bid in Controller.user.buildings)
            {
                foreach (Building b in allBuildings)
                {
                    if (bid == b.ID && !buildings.Contains(b))
                    {
                        buildings.Add(b);
                        break;
                    }
                }
            }
            buildings = buildings.OrderBy(c => c.Name).ToList();
        }
Пример #4
0
        private void usrCredits_Load(object sender, EventArgs e)
        {
            List <Building> allBuildings = new Buildings(false).buildings;

            LoadDefaultValues();
            buildings = new List <Building>();
            foreach (int bid in Controller.user.buildings)
            {
                foreach (Building b in allBuildings)
                {
                    if (bid == b.ID && !buildings.Contains(b))
                    {
                        buildings.Add(b);
                        break;
                    }
                }
            }
            buildings = buildings.OrderBy(c => c.Name).ToList();
            LoadBuildings();
        }
Пример #5
0
        private void ProcessContents(List <Dictionary <String, String> > contents)
        {
            List <Building> buildings = new Buildings(false).buildings;

            processedLines = 0;
            int enterProcess = 0;

            foreach (Dictionary <String, String> content in contents)
            {
                enterProcess++;
                String errorKey = "";
                try
                {
                    errorKey = "building";
                    String building = content["BUILDING"].Trim();
                    errorKey = "unit";
                    String   unit    = content["UNIT"].Trim();
                    DateTime trnDate = DateTime.Now;
                    errorKey = "date 1";
                    try { trnDate = DateTime.Parse(content["POST DATE"]); } catch (Exception ex) { MessageBox.Show("Error in post date: " + content["POST DATE"]); }
                    //MessageBox.Show(trnDate.ToString());
                    errorKey = "type";
                    String description = content["TYPE"].Trim() + " ";
                    errorKey     = "reading";
                    description += content["READING"].Trim() + " ";
                    String readDate = "";
                    errorKey = "date 2";
                    try { readDate = DateTime.Parse(content["READ DATE"]).ToString("dd/MM/yyyy"); } catch (Exception ex) { }
                    description += readDate;
                    errorKey     = "fee";
                    String amt = content["FEE"].Trim();
                    errorKey = "contra";
                    String contra      = content["CONTRA"].Trim();
                    String dataPath    = String.Empty;
                    int    trustPeriod = 0;
                    int    buildPeriod = 0;
                    int    journalType = 0;
                    foreach (Building b in buildings)
                    {
                        if (b.Abbr == building)
                        {
                            dataPath    = b.DataPath;
                            trustPeriod = Methods.getPeriod(trnDate, b.Period, out buildPeriod);
                            journalType = b.Journal;
                            break;
                        }
                    }
                    if (String.IsNullOrEmpty(dataPath))
                    {
                        continue;
                    }
                    String returner = String.Empty;
                    String strIn;
                    if (building == "RENT")
                    {
                        double amount = double.Parse(amt);
                        amount = amount * -1;
                        String supamt = amount.ToString();
                        PostLine(trnDate, dataPath, journalType, pastelPeriod, unit, "0000000", unit, description, amt, true, out strIn, out returner);
                        PostLine(trnDate, dataPath, journalType, pastelPeriod, contra, "0000000", unit, description, supamt, false, out strIn, out returner);
                    }
                    else
                    {
                        PostLine(trnDate, dataPath, journalType, pastelPeriod, unit, contra.Replace("/", ""), unit, description, amt, true, out strIn, out returner);
                    }
                    if (returner != "0")
                    {
                        MessageBox.Show(enterProcess.ToString() + ": " + returner + " - " + strIn);
                    }
                    else
                    {
                        processedLines += 1;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("key before = " + errorKey + " - " + ex.Message);
                }
            }
        }
Пример #6
0
        public static Dictionary <String, Building2> GetReportBuildings()
        {
            String status;
            Dictionary <String, Building2> repBuildings = new Dictionary <string, Building2>();

            repBuildings.Clear();
            String         centrecQuery = "SELECT centrec FROM tblSettings";
            SqlDataHandler dh           = new SqlDataHandler();
            DataSet        dsCentrec    = dh.GetData(centrecQuery, null, out status);
            String         centrecPath  = "";

            if (dsCentrec != null && dsCentrec.Tables.Count > 0 && dsCentrec.Tables[0].Rows.Count > 0)
            {
                centrecPath = dsCentrec.Tables[0].Rows[0]["centrec"].ToString();
            }
            else
            {
                MessageBox.Show(status);
            }
            List <Building> buildings = new Buildings(false).buildings;

            //String myPath = "";
            //String pastelTest = Controller.pastel.SetPath("CENTRE17", out myPath);
            //if (pastelTest != "0") { MessageBox.Show(myPath); }

            foreach (Building b in buildings)
            {
                try
                {
                    int    id               = b.ID;
                    String building         = b.Name;
                    String code             = b.Abbr;
                    String path             = b.DataPath;
                    int    period           = b.Period;
                    int    journal          = b.Journal;
                    String acc              = b.Trust;
                    String bank             = b.Bank;
                    String centrec_building = b.Centrec_Building.Replace("//", "").Replace("/", "");
                    String centrec          = b.Centrec_Account.Replace("//", "").Replace("/", "");
                    String business         = b.Business_Account;
                    String cString          = Controller.pastel.GetAccount(path, centrec_building);
                    //MessageBox.Show(centrec_building);
                    Account buildCentrec = (cString != "" && !cString.StartsWith("error") ? new Account(cString) : null);
                    String  aString      = Controller.pastel.GetCustomer(centrecPath, centrec);
                    //MessageBox.Show(centrec);
                    Customer centrecBuild = (aString != "" && !aString.StartsWith("error") ? new Customer(aString) : null);
                    if (buildCentrec != null && centrecBuild != null)
                    {
                        Building2 build = new Building2(id, building, code, path, period, journal, acc, centrec_building, centrec, business, buildCentrec, centrecBuild, bank);
                        repBuildings.Add(building, build);
                    }
                    else
                    {
                        Building2 build = new Building2(id, building, code, path, period, journal, acc, centrec_building, centrec, business, new Account("NONE"), new Customer(true, "NONE"), bank);
                        repBuildings.Add(building, build);
                    }
                    //break;
                }
                catch (Exception ex)
                {
                    Controller.HandleError(ex);
                }
            }
            return(repBuildings);
        }