Exemplo n.º 1
0
 public bool SaveFile(FlileModel CIM)
 {
     try
     {
         var query       = "INSERT INTO tbl_File (Name, Image, ClientId) VALUES('" + CIM.Name + "','" + CIM.Image + "','" + CIM.ClientId + "')";
         var rowAffected = _databaseCDb.ExecuteNonQuery(query, _connectionString);
         return(rowAffected > 0);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Exemplo n.º 2
0
        protected void ClientListGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            var sql = DatabaseCDb.ConnectionString();

            using (SqlConnection Sqlcon = new SqlConnection(sql))
            {
                FlileModel _ClientFile = new FlileModel();
                Sqlcon.Open();
                string query = "Select Name, Image From tbl_File Where ClientId=''" + _ClientFile.ClientId + "";
                using (SqlCommand cmd = new SqlCommand(query, Sqlcon))
                {
                }
            }
        }
Exemplo n.º 3
0
        public void Refresh()
        {
            var sql = databaseCDb.ConnectionStrings();

            using (SqlConnection Sqlcon = new SqlConnection(sql))
            {
                Sqlcon.Open();
                try
                {
                    //get Id
                    SqlCommand command2 = new SqlCommand("Select top 1 Id from tbl_ClientInfo order by Id desc", Sqlcon);
                    command2.CommandType = CommandType.Text;
                    var Id = command2.ExecuteScalar();
                    //end

                    //File Save Start
                    DataTable data = (DataTable)ViewState["Details"];

                    foreach (DataRow dr in data.Rows)
                    {
                        FlileModel _ClientFile = new FlileModel();
                        _ClientFile.Name     = dr["Name"].ToString();
                        _ClientFile.Image    = (byte[])dr["Image"];
                        _ClientFile.ClientId = Convert.ToInt32(Id);

                        string query = "INSERT INTO tbl_File VALUES(@Name, @Image, @ClientId)";
                        using (SqlCommand cmd = new SqlCommand(query, Sqlcon))
                        {
                            cmd.Parameters.AddWithValue("@Name", _ClientFile.Name);
                            cmd.Parameters.AddWithValue("@Image", _ClientFile.Image);
                            cmd.Parameters.AddWithValue("@ClientId", _ClientFile.ClientId);
                            cmd.ExecuteNonQuery();
                        }
                    }
                    Response.Redirect(Request.Url.AbsoluteUri);
                }
                catch
                {
                    //transaction.Rollback();
                }
                finally
                {
                    Sqlcon.Close();
                }
            }
        }