Beispiel #1
0
    public static Buletin GetBuletin(string fabricaid, string datatestare)
    {
        SqlConnection cnn = new SqlConnection(
            ConfigurationManager.ConnectionStrings
            ["fccl2ConnectionString"].ConnectionString);
        SqlCommand cmd = new SqlCommand();

        cmd.Connection  = cnn;
        cmd.CommandText = "select * from BuletinAnaliza where id_fabrica =" + fabricaid + " AND CONVERT(datetime,data,103) = CONVERT(datetime,'" + datatestare + "',103) ORDER BY ID DESC";
        cnn.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        int           nrb    = 0;
        string        datab  = "";

        if (reader.Read())
        {
            nrb   = Convert.ToInt32(reader["buletin_nr"]);
            datab = ((DateTime)reader["buletin_data"]).ToString("dd/MM/yyyy");
        }
        else
        {
            reader.Close();
            //  cmd.CommandText = "select * from BuletinAnaliza  ORDER BY ID DESC";
            cmd.CommandText = "select MAX(buletin_nr) AS MaxNrb from BuletinAnaliza";
            reader          = cmd.ExecuteReader();
            if (reader.Read())
            {
                nrb   = Convert.ToInt32(reader["MaxNrb"]);
                datab = (DateTime.Now).ToString("dd/MM/yyyy");
                //datab = Convert.ToString(reader["buletin_data"]);
            }
            nrb++;
        }
        reader.Close();
        cnn.Close();
        Buletin b = new Buletin();

        b.Nrb   = nrb;
        b.Datab = datab;
        return(b);
    }
Beispiel #2
0
    public static Buletin GetBuletin(string fabricaid, string datatestare)
    {
        SqlConnection cnn = new SqlConnection(
       ConfigurationManager.ConnectionStrings
       ["fccl2ConnectionString"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = cnn;
        cmd.CommandText = "select * from BuletinAnaliza where id_fabrica ="+fabricaid+" AND CONVERT(datetime,data,103) = CONVERT(datetime,'"+datatestare+"',103) ORDER BY ID DESC";
        cnn.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        int nrb=0;
        string datab = "";
        if (reader.Read())
        {
            nrb = Convert.ToInt32(reader["buletin_nr"]);         
            datab = ((DateTime)reader["buletin_data"]).ToString("dd/MM/yyyy");

        }
        else
        {
            reader.Close();
          //  cmd.CommandText = "select * from BuletinAnaliza  ORDER BY ID DESC";
            cmd.CommandText = "select MAX(buletin_nr) AS MaxNrb from BuletinAnaliza";
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                nrb = Convert.ToInt32(reader["MaxNrb"]);
                datab = (DateTime.Now).ToString("dd/MM/yyyy");
                //datab = Convert.ToString(reader["buletin_data"]);

            }
            nrb++;
        }
        reader.Close();
        cnn.Close();
        Buletin b = new Buletin();
        b.Nrb = nrb;
        b.Datab = datab;
        return b;
    }
Beispiel #3
0
        private Person GetNewPerson()
        {
            var nume       = txtBxPersonName.Text.GetString(out string Name);
            var prenume    = txtBxPersonFamily.Text.GetString(out string secondName);
            var patronimic = txtBxPersonLastName.Text.GetString(out string LastName);
            var idno       = txtBxBuletinIDNO.Text.GetString(out string IDNO);

            //trebuie de scos verificarea idno la null sau empty pentru o mai buna treaba
            if (nume && prenume && patronimic && idno)
            {
                var buletin = new Buletin
                {
                    BuletinBirthDate    = dateTimePickerBirthDate.Value,
                    BuletinBirthPlace   = txtBxBirthPlace.Text,
                    BuletinBloodGroup   = cmBxBloodGroup.Text,
                    BuletinHeight       = txtBxHeight.Text,
                    BuletinEyesColor    = txtBxEyesColor.Text,
                    BuletinSex          = cmBxSex.Text,
                    BuletinSeria        = txtBxBuletinSeria.Text,
                    BuletinPersonalCode = IDNO,
                    BuletinCreateDate   = dateTimePickerCreationDateBuletin.Value,
                    BuletinExpireDate   = dateTimePickerExpireBuletin.Value
                };

                var person = new Person
                {
                    PersonName     = Name,
                    PersonFamily   = secondName,
                    PersonLastName = LastName,
                    Buletin        = buletin,
                    BuletinId      = buletin.BuletinId
                };

                return(person);
            }
            else
            {
                var buletin = new Buletin
                {
                    BuletinBirthDate    = dateTimePickerBirthDate.Value,
                    BuletinBirthPlace   = txtBxBirthPlace.Text,
                    BuletinBloodGroup   = cmBxBloodGroup.Text,
                    BuletinHeight       = txtBxHeight.Text,
                    BuletinEyesColor    = txtBxEyesColor.Text,
                    BuletinSex          = cmBxSex.Text,
                    BuletinSeria        = txtBxBuletinSeria.Text,
                    BuletinPersonalCode = "0000 0000 0000 0000 0000",
                    BuletinCreateDate   = dateTimePickerCreationDateBuletin.Value,
                    BuletinExpireDate   = dateTimePickerExpireBuletin.Value
                };

                var person = new Person
                {
                    PersonName     = "NoName",
                    PersonFamily   = "NoSecondName",
                    PersonLastName = "NoLastName",
                    Buletin        = buletin,
                    BuletinId      = buletin.BuletinId
                };
                return(person);
            }
        }