Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                List <ObjectRep> list = new List <ObjectRep>();
                string           line;
                StreamReader     fs = new StreamReader("object.txt");

                while ((line = fs.ReadLine()) != null)
                {
                    ObjectRep obj       = new ObjectRep();
                    string[]  splitLine = line.Split('|');
                    obj.address     = splitLine[0];
                    obj.problem     = splitLine[1];
                    obj.cost        = Convert.ToInt32(splitLine[2]);
                    obj.brigade     = splitLine[3];
                    obj.firstday    = new int[3];
                    obj.firstday[0] = Convert.ToInt32(splitLine[4]);
                    obj.firstday[1] = Convert.ToInt32(splitLine[5]);
                    obj.firstday[2] = Convert.ToInt32(splitLine[6]);
                    obj.lastday     = new int[3];
                    obj.lastday[0]  = Convert.ToInt32(splitLine[7]);
                    obj.lastday[1]  = Convert.ToInt32(splitLine[8]);
                    obj.lastday[2]  = Convert.ToInt32(splitLine[9]);
                    obj.fixproblem  = splitLine[10];
                    list.Add(obj);
                }
                fs.Close();

                foreach (ObjectRep obj in list)
                {
                    if (Types.SelectedIndexObject == obj.address)
                    {
                        obj.lastday[0] = Convert.ToInt32(textBox1.Text);
                        obj.lastday[1] = Convert.ToInt32(textBox3.Text);
                        obj.lastday[2] = Convert.ToInt32(textBox4.Text);
                        obj.fixproblem = textBox2.Text;
                        MessageBox.Show("успешно!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    }
                }

                StreamWriter sw = new StreamWriter("object.txt");
                int          i  = 0;
                foreach (ObjectRep obj in list)
                {
                    if (i == list.Count - 1)
                    {
                        sw.Write(obj.GetData());
                        continue;
                    }
                    sw.WriteLine(obj.GetData());
                    i++;
                }
                sw.Close();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Exemple #2
0
        public Form16()
        {
            InitializeComponent();
            textBox1.ReadOnly = true;
            textBox2.ReadOnly = true;
            textBox3.ReadOnly = true;
            textBox4.ReadOnly = true;
            textBox5.ReadOnly = true;
            textBox6.ReadOnly = true;
            textBox7.ReadOnly = true;

            List <ObjectRep> list = new List <ObjectRep>();
            string           line;
            StreamReader     fs = new StreamReader("object.txt");

            while ((line = fs.ReadLine()) != null)
            {
                ObjectRep obj       = new ObjectRep();
                string[]  splitLine = line.Split('|');
                obj.address     = splitLine[0];
                obj.problem     = splitLine[1];
                obj.cost        = Convert.ToInt32(splitLine[2]);
                obj.brigade     = splitLine[3];
                obj.firstday    = new int[3];
                obj.firstday[0] = Convert.ToInt32(splitLine[4]);
                obj.firstday[1] = Convert.ToInt32(splitLine[5]);
                obj.firstday[2] = Convert.ToInt32(splitLine[6]);
                obj.lastday     = new int[3];
                obj.lastday[0]  = Convert.ToInt32(splitLine[7]);
                obj.lastday[1]  = Convert.ToInt32(splitLine[8]);
                obj.lastday[2]  = Convert.ToInt32(splitLine[9]);
                obj.fixproblem  = splitLine[10];
                list.Add(obj);
            }
            fs.Close();

            foreach (ObjectRep obj in list)
            {
                if (Types.SelectedIndexObject == obj.address)
                {
                    textBox1.Text = obj.address;
                    textBox2.Text = obj.problem;
                    textBox4.Text = Convert.ToString(obj.cost);
                    textBox3.Text = obj.brigade;
                    textBox5.Text = Convert.ToString(obj.firstday[0] + "." + obj.firstday[1] + "." + obj.firstday[2]);
                    textBox7.Text = Convert.ToString(obj.lastday[0] + "." + obj.lastday[1] + "." + obj.lastday[2]);
                    textBox6.Text = obj.fixproblem;
                }
            }
        }
Exemple #3
0
        public Form8()
        {
            InitializeComponent();
            string       line;
            StreamReader fs = new StreamReader("object.txt");

            while ((line = fs.ReadLine()) != null)
            {
                ObjectRep objrep    = new ObjectRep();
                string[]  splitLine = line.Split('|');
                objrep.address = splitLine[0];
                listBox1.Items.Add(objrep.address);
            }
            fs.Close();
        }
Exemple #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                List <ObjectRep> list = new List <ObjectRep>();
                string           line;
                StreamReader     fs = new StreamReader("object.txt");

                while ((line = fs.ReadLine()) != null)
                {
                    ObjectRep obj       = new ObjectRep();
                    string[]  splitLine = line.Split('|');
                    obj.address     = splitLine[0];
                    obj.problem     = splitLine[1];
                    obj.cost        = Convert.ToInt32(splitLine[2]);
                    obj.brigade     = splitLine[3];
                    obj.firstday    = new int[3];
                    obj.firstday[0] = Convert.ToInt32(splitLine[4]);
                    obj.firstday[1] = Convert.ToInt32(splitLine[5]);
                    obj.firstday[2] = Convert.ToInt32(splitLine[6]);
                    obj.lastday     = new int[3];
                    obj.lastday[0]  = Convert.ToInt32(splitLine[7]);
                    obj.lastday[1]  = Convert.ToInt32(splitLine[8]);
                    obj.lastday[2]  = Convert.ToInt32(splitLine[9]);
                    obj.fixproblem  = splitLine[10];
                    list.Add(obj);
                }
                fs.Close();
                int sum = 0;

                foreach (ObjectRep obj in list)
                {
                    if (obj.lastday[0] != 0)
                    {
                        DateTime dt1 = new DateTime(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text), Convert.ToInt32(textBox3.Text));
                        DateTime dt2 = new DateTime(Convert.ToInt32(textBox5.Text), Convert.ToInt32(textBox4.Text), Convert.ToInt32(textBox6.Text));
                        DateTime dt3 = new DateTime(obj.firstday[2], obj.firstday[1], obj.firstday[0]);
                        DateTime dt4 = new DateTime(obj.lastday[2], obj.lastday[1], obj.lastday[0]);

                        int compare1 = DateTime.Compare(dt3, dt1);
                        int compare2 = DateTime.Compare(dt3, dt4);
                        int compare3 = DateTime.Compare(dt3, dt2);
                        int compare4 = DateTime.Compare(dt4, dt1);
                        int compare5 = DateTime.Compare(dt4, dt3);
                        int compare6 = DateTime.Compare(dt4, dt2);

                        if ((compare1 > 0 || compare1 == 0) && (compare4 > 0 || compare4 == 0))
                        {
                            if ((compare2 < 0 || compare2 == 0) && (compare5 > 0 || compare5 == 0))
                            {
                                if ((compare3 < 0 || compare3 == 0) && (compare6 < 0 || compare6 == 0))
                                {
                                    sum = sum + obj.cost;
                                }
                            }
                        }
                    }
                }
                textBox7.Text = Convert.ToString(sum);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }