예제 #1
0
 //конструктор
 public Human(string name, string sname, string fname, DateTime brn, bool life, DateTime dth, string[] par, int childq, string[] chi, string id)
 {
     if (ValidateSingle(name))
     {
         Name = name;
     }
     else
     {
         throw new FormatException(Properties.Resources.Error_Validate_Name);
     }
     if (ValidateSingle(sname))
     {
         SName = sname;
     }
     else
     {
         throw new FormatException(Properties.Resources.Error_Validate_SName);
     }
     if (ValidateSingle(fname))
     {
         FName = fname;
     }
     else
     {
         throw new FormatException(Properties.Resources.Error_Validate_FName);
     }
     BornDate = brn;
     Life     = life;
     if (Validate_Death_Date(dth))
     {
         DeathDate = dth;
     }
     else
     {
         throw new FormatException(Properties.Resources.Error_Validate_Death_Date);
     }
     Parents  = par;
     Childq   = childq;
     Children = chi;
     humaninf = SName + " " + Name.Substring(0, 1) + "." + FName.Substring(0, 1) + ".   " + BornDate.Year + "г.";
     if (ValidateID(id))
     {
         ID = id;
     }
     else
     {
         throw new FormatException(Properties.Resources.Error_Validate_ID);
     }
 }
예제 #2
0
        public void _dropdownWorker_SelectedIndexChanged(object sender, EventArgs e)
        {
            string        WorkerID = _dropdownWorker.SelectedValue.ToString();
            String        Conn     = ConfigurationManager.ConnectionStrings["ConnString_WEB_ASSET_DB"].ConnectionString;
            SqlConnection Connect  = new SqlConnection(Conn);

            Connect.Open();
            SqlCommand Cmd = new SqlCommand("SELECT COUNT (*) FROM BADGE WHERE WORKERID=@WorkerID", Connect);

            Cmd.Parameters.AddWithValue("@WorkerID", WorkerID);
            Int32 Count = (Int32)Cmd.ExecuteScalar();

            Connect.Close();
            if (Count == 0)
            {
                Connect.Open();
                Cmd = new SqlCommand("SELECT WORKERID, WORKERIMAGE, WORKERFNAME, WORKERLNAME, WORKERDOB FROM WORKER WHERE WORKERID=@WorkerID", Connect);
                Cmd.Parameters.AddWithValue("@WorkerID", WorkerID);
                SqlDataReader Reader = Cmd.ExecuteReader();
                while (Reader.Read())
                {
                    _labelID.Text         = Reader["WORKERID"].ToString();
                    _imageWorker.ImageUrl = Reader["WORKERIMAGE"].ToString();
                    //_txtValidFrom.Text = Reader["BADGEFROM"].ToString();
                    //_txtValidTo.Text = Reader["BADGETO"].ToString();
                    string   FirstName   = Reader["WORKERFNAME"].ToString();
                    string   DateOfBirth = Reader["WORKERDOB"].ToString();
                    DateTime DOB         = Convert.ToDateTime(DateOfBirth);
                    string   Birthdate   = DOB.Date.ToString("MM/dd/yyyy");
                    string   FName;
                    if (FirstName.Length < 4)
                    {
                        FName = FirstName + "0";
                        FName = FName.Substring(0, 4);
                    }
                    else
                    {
                        FName = FirstName.Substring(0, 4);
                    }
                    int    IdWork = Convert.ToInt32(_labelID.Text);
                    string WorkID = IdWork.ToString("00000");
                    _txtBadgeCode.Text = WorkID + FName.Replace(" ", string.Empty) + Birthdate.Replace("/", string.Empty);
                    _txtBadgeCode.Text = _txtBadgeCode.Text.ToUpper();
                    _txtValidFrom.Text = "";
                    _txtValidTo.Text   = "";
                    _dropdownBadgeStat.ClearSelection();
                }
                Connect.Close();
                Cmd.Parameters.Clear();
            }
            else
            {
                Connect.Open();
                Cmd = new SqlCommand("SELECT BADGE.WORKERID, WORKERIMAGE, WORKERFNAME, WORKERLNAME, WORKERDOB, BADGE.BADGEFROM, BADGE.BADGETO,BADGE.BADGESTAT FROM WORKER JOIN BADGE ON BADGE.WORKERID=WORKER.WORKERID WHERE BADGE.WORKERID=@WorkerID", Connect);
                Cmd.Parameters.AddWithValue("@WorkerID", WorkerID);
                SqlDataReader Reader = Cmd.ExecuteReader();
                while (Reader.Read())
                {
                    _labelID.Text         = Reader["WORKERID"].ToString();
                    _imageWorker.ImageUrl = Reader["WORKERIMAGE"].ToString();
                    //_txtValidFrom.Text = Reader["BADGEFROM"].ToString();
                    //_txtValidTo.Text = Reader["BADGETO"].ToString();
                    DateTime From = Convert.ToDateTime(Reader["BADGEFROM"].ToString());
                    DateTime To   = Convert.ToDateTime(Reader["BADGETO"].ToString());
                    _txtValidFrom.Text = From.ToString("MM/dd/yyyy");
                    _txtValidTo.Text   = To.ToString("MM/dd/yyyy");
                    string   FirstName   = Reader["WORKERFNAME"].ToString();
                    string   DateOfBirth = Reader["WORKERDOB"].ToString();
                    DateTime DOB         = Convert.ToDateTime(DateOfBirth);
                    string   Birthdate   = DOB.Date.ToString("MM/dd/yyyy");
                    string   FName;
                    if (FirstName.Length < 4)
                    {
                        FName = FirstName + "0";
                        FName = FName.Substring(0, 4);
                    }
                    else
                    {
                        FName = FirstName.Substring(0, 4);
                    }
                    int    IdWork = Convert.ToInt32(_labelID.Text);
                    string WorkID = IdWork.ToString("00000");
                    _txtBadgeCode.Text = WorkID + FName.Replace(" ", string.Empty) + Birthdate.Replace("/", string.Empty);
                    _txtBadgeCode.Text = _txtBadgeCode.Text.ToUpper();
                    _dropdownBadgeStat.SelectedValue = Reader["BADGESTAT"].ToString();
                }
                Connect.Close();
                Cmd.Parameters.Clear();
            }
        }
예제 #3
0
    protected void Btninsert_Click(object sender, EventArgs e)
    {
        obj.connect();
        string Titl, FName, CatGry, SubCat, AlbuMusic, Singr, Yar, Composr, Size, Formt, Directrr, Duration, BitRte, Genre, Desc;

        Titl  = Txttitle.Text.Trim();
        FName = "~/music/" + FileUpload1.FileName.Trim();

        string sql = "Select id from maintable where title='" + Titl + "' and filename='" + FName + "'";

        cmd = new SqlCommand(sql, obj.con);
        SqlDataReader dr;

        dr = cmd.ExecuteReader();
        if (dr.HasRows)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert ('This song is Already stored in database');", true);
        }
        else
        {
            dr.Close();
            Titl  = Txttitle.Text.ToString();
            FName = FileUpload1.FileName;
            string img         = "~/image/" + FileUpload2.FileName;
            int    a           = FileUpload1.PostedFile.ContentLength;
            float  AB          = (float)a / (1024 * 1024);
            int    li          = FName.LastIndexOf(".");
            string fo          = FName.Substring(li + 1);
            string newfilename = "~/music/" + FName;


            CatGry    = DropDownCateg.Text.ToString();
            SubCat    = DropDSongtype.Text.ToString();
            AlbuMusic = Txtmovie.Text.ToString();
            Singr     = Txtsing.Text.ToString();
            Yar       = Txtyr.Text.ToString();
            Composr   = Txtcompos.Text.ToString();
            Size      = AB.ToString() + "mb";
            Formt     = fo.ToString();
            Directrr  = TxtDirec.Text.ToString();
            Duration  = Txtdur.Text.ToString();
            BitRte    = Txtbit.Text.ToString();
            Genre     = Txtgen.Text.ToString();
            Desc      = Txtdes.Text.ToString();
            int p = obj.insert_data(Titl, newfilename, CatGry, SubCat, AlbuMusic, Singr, Yar, Composr, Size, Formt, Directrr, Duration, BitRte, Genre, Desc, 1, img);
            if (p > 0)
            {
                FileUpload1.SaveAs(Server.MapPath("~/Music/") + FName);
                FileUpload2.SaveAs(Server.MapPath("~/image/") + FileUpload2.FileName);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Insert successfully');", true);
                Txttitle.Text  = "";
                Txtmovie.Text  = "";
                Txtsing.Text   = "";
                Txtyr.Text     = "";
                Txtcompos.Text = "";
                TxtDirec.Text  = "";
                Txtdur.Text    = "";
                Txtbit.Text    = "";
                Txtgen.Text    = "";
                Txtdes.Text    = "";
            }
            else
            {
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('Not Insert');", true);
                Response.Redirect("UploadSongs.aspx");
            }
        }
    }